Java Code Examples for jdk.xml.internal.JdkXmlUtils#OVERRIDE_PARSER_DEFAULT
The following examples show how to use
jdk.xml.internal.JdkXmlUtils#OVERRIDE_PARSER_DEFAULT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XPathAPI.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 2
Source File: XPathAPI.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 3
Source File: XPathAPI.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 4
Source File: XPathAPI.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 5
Source File: XPathAPI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param namespaceNode The node from which prefixes in the XPath will be resolved to namespaces. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval(Node contextNode, String str, Node namespaceNode) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); // Create an object to resolve namespace prefixes. // XPath namespaces are resolved from the input context node's document element // if it is a root node, or else the current context node (for lack of a better // resolution space, given the simplicity of this sample code). PrefixResolverDefault prefixResolver = new PrefixResolverDefault( (namespaceNode.getNodeType() == Node.DOCUMENT_NODE) ? ((Document) namespaceNode).getDocumentElement() : namespaceNode); // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result // return xpath.execute(xpathSupport, contextNode, prefixResolver); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 6
Source File: XPathAPI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 7
Source File: CachedXPathAPI.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 8
Source File: XPathAPI.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 9
Source File: CachedXPathAPI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 10
Source File: XPathAPI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 11
Source File: CachedXPathAPI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 12
Source File: XPathAPI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 13
Source File: CachedXPathAPI.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 14
Source File: XPathAPI.java From JDKSourceCode1.8 with MIT License | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public static XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 15
Source File: CachedXPathAPI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Evaluate XPath string to an XObject. * XPath namespace prefixes are resolved from the namespaceNode. * The implementation of this is a little slow, since it creates * a number of objects each time it is called. This could be optimized * to keep the same objects around, but then thread-safety issues would arise. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @param prefixResolver Will be called if the parser encounters namespace * prefixes, to resolve the prefixes to URLs. * @return An XObject, which can be used to obtain a string, number, nodelist, etc, should never be null. * @see com.sun.org.apache.xpath.internal.objects.XObject * @see com.sun.org.apache.xpath.internal.objects.XNull * @see com.sun.org.apache.xpath.internal.objects.XBoolean * @see com.sun.org.apache.xpath.internal.objects.XNumber * @see com.sun.org.apache.xpath.internal.objects.XString * @see com.sun.org.apache.xpath.internal.objects.XRTreeFrag * * @throws TransformerException */ public XObject eval( Node contextNode, String str, PrefixResolver prefixResolver) throws TransformerException { // Since we don't have a XML Parser involved here, install some default support // for things like namespaces, etc. // (Changed from: XPathContext xpathSupport = new XPathContext(); // because XPathContext is weak in a number of areas... perhaps // XPathContext should be done away with.) // Create the XPath object. XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null); // Execute the XPath, and have it return the result XPathContext xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode); return xpath.execute(xpathSupport, ctxtNode, prefixResolver); }
Example 16
Source File: CachedXPathAPI.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.dtm.DTM}.</p> */ public CachedXPathAPI() { xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); }
Example 17
Source File: CachedXPathAPI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.dtm.DTM}.</p> */ public CachedXPathAPI() { xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); }
Example 18
Source File: CachedXPathAPI.java From JDKSourceCode1.8 with MIT License | 2 votes |
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.dtm.DTM}.</p> */ public CachedXPathAPI() { xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); }
Example 19
Source File: CachedXPathAPI.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.dtm.DTM}.</p> */ public CachedXPathAPI() { xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); }
Example 20
Source File: CachedXPathAPI.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * <p>Default constructor. Establishes its own {@link XPathContext}, and hence * its own {@link com.sun.org.apache.xml.internal.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 com.sun.org.apache.xml.internal.dtm.DTM}.</p> */ public CachedXPathAPI() { xpathSupport = new XPathContext(JdkXmlUtils.OVERRIDE_PARSER_DEFAULT); }