/** * Tells the system to use (restore) the default (initial) XPath system used by this FreeMarker * version on this system. */ public static void useDefaultXPathSupport() { xpathSupportClass = null; jaxenXPathSupport = null; try { useXalanXPathSupport(); } catch (Exception e) {; // ignore } if (xpathSupportClass == null) try { useSunInternalXPathSupport(); } catch (Exception e) {; // ignore } if (xpathSupportClass == null) try { useJaxenXPathSupport(); } catch (Exception e) {; // ignore } }
static void setFreeMarkerXPathEngine(String xpathEngine) throws IllegalConfigurationException { if (xpathEngine.equals(Engine.XPATH_ENGINE_DONT_SET)) {; // do nothing } else if (xpathEngine.equals(Engine.XPATH_ENGINE_DEFAULT)) { NodeModel.useDefaultXPathSupport(); } else if (xpathEngine.equals(Engine.XPATH_ENGINE_XALAN)) { try { NodeModel.useXalanXPathSupport(); } catch (Exception e) { throw new IllegalConfigurationException("Failed to use Xalan XPath engine.", e); } } else if (xpathEngine.equals(Engine.XPATH_ENGINE_JAXEN)) { try { NodeModel.useJaxenXPathSupport(); } catch (Exception e) { throw new IllegalConfigurationException("Failed to use Jaxen XPath engine.", e); } } else { Class cl; try { cl = MiscUtil.classForName(xpathEngine); } catch (ClassNotFoundException e) { throw new IllegalConfigurationException( "Custom XPath engine adapter class " + StringUtil.jQuote(xpathEngine) + " not found. " + "Note that the reserved names are: " + StringUtil.jQuote(Engine.XPATH_ENGINE_DONT_SET) + ", " + StringUtil.jQuote(Engine.XPATH_ENGINE_DEFAULT) + ", " + StringUtil.jQuote(Engine.XPATH_ENGINE_XALAN) + ", " + StringUtil.jQuote(Engine.XPATH_ENGINE_JAXEN) + ".", e); } NodeModel.setXPathSupportClass(cl); } }