/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link org.apache.xml.dtm.DTMManager}. * Good choice for simple uses.</p> * <p>Note that any particular instance of {@link CachedXPathAPI} must not be * operated upon by multiple threads without synchronization; we do * not currently support multithreaded access to a single * {@link org.apache.xml.dtm.DTM}.</p> */ public CachedXPathAPI() { // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 expressions. xpathSupport = new XPathContext(false); }
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link org.apache.xml.dtm.DTMManager}. * Good choice for simple uses.</p> * <p>Note that any particular instance of {@link CachedXPathAPI} must not be * operated upon by multiple threads without synchronization; we do * not currently support multithreaded access to a single * {@link org.apache.xml.dtm.DTM}.</p> */ public CachedXPathAPI() { // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 expressions. xpathSupport = new XPathContext(false); }
private XObject eval ( Object contextItem ) throws javax.xml.transform.TransformerException { org.apache.xpath.XPathContext xpathSupport = null; // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 // expressions. if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing ); xpathSupport = new org.apache.xpath.XPathContext(jep, false); } else { xpathSupport = new org.apache.xpath.XPathContext(false); } xpathSupport.setVarStack(new JAXPVariableStack(variableResolver)); XObject xobj = null; Node contextNode = (Node)contextItem; // We always need to have a ContextNode with Xalan XPath implementation // To allow simple expression evaluation like 1+1 we are setting // dummy Document as Context Node if ( contextNode == null ) { contextNode = getDummyDocument(); } xobj = xpath.execute(xpathSupport, contextNode, prefixResolver ); return xobj; }
private XObject eval ( Object contextItem ) throws javax.xml.transform.TransformerException { org.apache.xpath.XPathContext xpathSupport = null; // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 // expressions. if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing ); xpathSupport = new org.apache.xpath.XPathContext(jep, false); } else { xpathSupport = new org.apache.xpath.XPathContext(false); } xpathSupport.setVarStack(new JAXPVariableStack(variableResolver)); XObject xobj = null; Node contextNode = (Node)contextItem; // We always need to have a ContextNode with Xalan XPath implementation // To allow simple expression evaluation like 1+1 we are setting // dummy Document as Context Node if ( contextNode == null ) { contextNode = getDummyDocument(); } xobj = xpath.execute(xpathSupport, contextNode, prefixResolver ); return xobj; }
private XObject eval(String expression, Object contextItem) throws javax.xml.transform.TransformerException { org.apache.xpath.XPath xpath = new org.apache.xpath.XPath( expression, null, prefixResolver, org.apache.xpath.XPath.SELECT ); org.apache.xpath.XPathContext xpathSupport = null; // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 // expressions. if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing ); xpathSupport = new org.apache.xpath.XPathContext(jep, false); } else { xpathSupport = new org.apache.xpath.XPathContext(false); } XObject xobj = null; xpathSupport.setVarStack(new JAXPVariableStack(variableResolver)); // If item is null, then we will create a a Dummy contextNode if ( contextItem instanceof Node ) { xobj = xpath.execute (xpathSupport, (Node)contextItem, prefixResolver ); } else { xobj = xpath.execute ( xpathSupport, DTM.NULL, prefixResolver ); } return xobj; }
private XObject eval(String expression, Object contextItem) throws javax.xml.transform.TransformerException { org.apache.xpath.XPath xpath = new org.apache.xpath.XPath( expression, null, prefixResolver, org.apache.xpath.XPath.SELECT ); org.apache.xpath.XPathContext xpathSupport = null; // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 // expressions. if ( functionResolver != null ) { JAXPExtensionsProvider jep = new JAXPExtensionsProvider( functionResolver, featureSecureProcessing ); xpathSupport = new org.apache.xpath.XPathContext(jep, false); } else { xpathSupport = new org.apache.xpath.XPathContext(false); } XObject xobj = null; xpathSupport.setVarStack(new JAXPVariableStack(variableResolver)); // If item is null, then we will create a a Dummy contextNode if ( contextItem instanceof Node ) { xobj = xpath.execute (xpathSupport, (Node)contextItem, prefixResolver ); } else { xobj = xpath.execute ( xpathSupport, DTM.NULL, prefixResolver ); } return xobj; }
XPathContext xpathSupport = new XPathContext(false); XPathContext xpathSupport = new XPathContext(false);
XPathContext xpathSupport = new XPathContext(false); XPathContext xpathSupport = new XPathContext(false);
XPathContext xpathSupport = new XPathContext(false);
XPathContext xpathSupport = new XPathContext(false);
XPathContext xpathSupport = new XPathContext(false);
/** * Construct a TransformerImpl. * * @param stylesheet The root of the stylesheet tree. */ public TransformerImpl(StylesheetRoot stylesheet) // throws javax.xml.transform.TransformerException { m_optimizer = stylesheet.getOptimizer(); m_incremental = stylesheet.getIncremental(); m_source_location = stylesheet.getSource_location(); setStylesheet(stylesheet); XPathContext xPath = new XPathContext(this); xPath.setIncremental(m_incremental); xPath.getDTMManager().setIncremental(m_incremental); xPath.setSource_location(m_source_location); xPath.getDTMManager().setSource_location(m_source_location); if (stylesheet.isSecureProcessing()) xPath.setSecureProcessing(true); setXPathContext(xPath); getXPathContext().setNamespaceContext(stylesheet); }
/** * Construct a TransformerImpl. * * @param stylesheet The root of the stylesheet tree. */ public TransformerImpl(StylesheetRoot stylesheet) // throws javax.xml.transform.TransformerException { m_optimizer = stylesheet.getOptimizer(); m_incremental = stylesheet.getIncremental(); m_source_location = stylesheet.getSource_location(); setStylesheet(stylesheet); XPathContext xPath = new XPathContext(this); xPath.setIncremental(m_incremental); xPath.getDTMManager().setIncremental(m_incremental); xPath.setSource_location(m_source_location); xPath.getDTMManager().setSource_location(m_source_location); if (stylesheet.isSecureProcessing()) xPath.setSecureProcessing(true); setXPathContext(xPath); getXPathContext().setNamespaceContext(stylesheet); m_stackGuard = new StackGuard(this); }
/** * Create and return an instance of Xalan's XPathContext that can be used to * compile an XPath expression. */ private XPathContext getXPathContext() { if (xpContext == null) xpContext = new XPathContext(); return xpContext; }
/** * Create and return an instance of Xalan's XPathContext that can be used to * compile an XPath expression. */ private XPathContext getXPathContext() { if (xpContext == null) xpContext = new XPathContext(); return xpContext; }
/** * Create and return an instance of Xalan's XPathContext that can be used to * compile an XPath expression. */ private XPathContext getXPathContext() { if (xpContext == null) xpContext = new XPathContext(); return xpContext; }
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link org.apache.xml.dtm.DTMManager}. * Good choice for simple uses.</p> * <p>Note that any particular instance of {@link CachedXPathAPI} must not be * operated upon by multiple threads without synchronization; we do * not currently support multithreaded access to a single * {@link org.apache.xml.dtm.DTM}.</p> */ public CachedXPathAPI() { // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 expressions. xpathSupport = new XPathContext(false); }
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link org.apache.xml.dtm.DTMManager}. * Good choice for simple uses.</p> * <p>Note that any particular instance of {@link CachedXPathAPI} must not be * operated upon by multiple threads without synchronization; we do * not currently support multithreaded access to a single * {@link org.apache.xml.dtm.DTM}.</p> */ public CachedXPathAPI() { // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 expressions. xpathSupport = new XPathContext(false); }
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link org.apache.xml.dtm.DTMManager}. * Good choice for simple uses.</p> * <p>Note that any particular instance of {@link CachedXPathAPI} must not be * operated upon by multiple threads without synchronization; we do * not currently support multithreaded access to a single * {@link org.apache.xml.dtm.DTM}.</p> */ public CachedXPathAPI() { // Create an XPathContext that doesn't support pushing and popping of // variable resolution scopes. Sufficient for simple XPath 1.0 expressions. xpathSupport = new XPathContext(false); }
XPathContext xc = new XPathContext(); xc.addNamespace("ns4", "http://sample.xml.com/ns4"); xc.addNamespace("ns1", "http://sample.xml.com/ns1"); doc.query("ns4:parent/ns4:child1/ns1:child2", xc);