/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a single node. * XPath namespace prefixes are resolved from the namespaceNode. * * @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 The first node found that matches the XPath, or null. * * @throws TransformerException */ public Node selectSingleNode( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Have the XObject return its result as a NodeSetDTM. NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode); // Return the first node, or null return nl.nextNode(); }
/** * Use an XPath string to select a single node. * XPath namespace prefixes are resolved from the namespaceNode. * * @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 The first node found that matches the XPath, or null. * * @throws TransformerException */ public Node selectSingleNode( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Have the XObject return its result as a NodeSetDTM. NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode); // Return the first node, or null return nl.nextNode(); }
protected boolean evaluate(InputSource inputSource) { try { DocumentBuilder dbuilder = createDocumentBuilder(); Document doc = dbuilder.parse(inputSource); //An XPath expression could return a true or false value instead of a node. //eval() is a better way to determine the boolean value of the exp. //For compliance with legacy behavior where selecting an empty node returns true, //selectNodeIterator is attempted in case of a failure. CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); XObject result = cachedXPathAPI.eval(doc, xpath); if (result.bool()) return true; else { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } } catch (Throwable e) { return false; } }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a nodelist. * XPath namespace prefixes are resolved from the contextNode. * * @param contextNode The node to start searching from. * @param str A valid XPath string. * @return A NodeIterator, should never be null. * * @throws TransformerException */ public NodeIterator selectNodeIterator(Node contextNode, String str) throws TransformerException { return selectNodeIterator(contextNode, str, contextNode); }
/** * Use an XPath string to select a single node. * XPath namespace prefixes are resolved from the namespaceNode. * * @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 The first node found that matches the XPath, or null. * * @throws TransformerException */ public Node selectSingleNode( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Have the XObject return its result as a NodeSetDTM. NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode); // Return the first node, or null return nl.nextNode(); }
/** * Use an XPath string to select a single node. * XPath namespace prefixes are resolved from the namespaceNode. * * @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 The first node found that matches the XPath, or null. * * @throws TransformerException */ public Node selectSingleNode( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Have the XObject return its result as a NodeSetDTM. NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode); // Return the first node, or null return nl.nextNode(); }
/** * Use an XPath string to select a single node. * XPath namespace prefixes are resolved from the namespaceNode. * * @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 The first node found that matches the XPath, or null. * * @throws TransformerException */ public Node selectSingleNode( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Have the XObject return its result as a NodeSetDTM. NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode); // Return the first node, or null return nl.nextNode(); }
private boolean evaluate(byte[] data) { try { InputSource inputSource = new InputSource(new ByteArrayInputStream(data)); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder dbuilder = factory.newDocumentBuilder(); Document doc = dbuilder.parse(inputSource); CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); XObject result = cachedXPathAPI.eval(doc, xpath); if (result.bool()) return true; else { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } } catch (Throwable e) { return false; } }
protected boolean evaluate(InputSource inputSource) { try { DocumentBuilder dbuilder = createDocumentBuilder(); Document doc = dbuilder.parse(inputSource); //An XPath expression could return a true or false value instead of a node. //eval() is a better way to determine the boolean value of the exp. //For compliance with legacy behavior where selecting an empty node returns true, //selectNodeIterator is attempted in case of a failure. CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); XObject result = cachedXPathAPI.eval(doc, xpath); if (result.bool()) return true; else { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } } catch (Throwable e) { return false; } }
protected boolean evaluate(InputSource inputSource) { try { DocumentBuilder dbuilder = createDocumentBuilder(); Document doc = dbuilder.parse(inputSource); //An XPath expression could return a true or false value instead of a node. //eval() is a better way to determine the boolean value of the exp. //For compliance with legacy behavior where selecting an empty node returns true, //selectNodeIterator is attempted in case of a failure. CachedXPathAPI cachedXPathAPI = new CachedXPathAPI(); XObject result = cachedXPathAPI.eval(doc, xpath); if (result.bool()) return true; else { NodeIterator iterator = cachedXPathAPI.selectNodeIterator(doc, xpath); return (iterator.nextNode() != null); } } catch (Throwable e) { return false; } }