/** * Use an XPath string to select a nodelist. * 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 A NodeIterator, should never be null. * * @throws TransformerException */ public static NodeList selectNodeList( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Execute the XPath, and have it return the result XObject list = eval(contextNode, str, namespaceNode); // Return a NodeList. return list.nodelist(); }
/** * Use an XPath string to select a nodelist. * 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 A NodeIterator, should never be null. * * @throws TransformerException */ public NodeList selectNodeList( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Execute the XPath, and have it return the result XObject list = eval(contextNode, str, namespaceNode); // Return a NodeList. return list.nodelist(); }
/** * Use an XPath string to select a nodelist. * 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 A NodeIterator, should never be null. * * @throws TransformerException */ public static NodeList selectNodeList( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Execute the XPath, and have it return the result XObject list = eval(contextNode, str, namespaceNode); // Return a NodeList. return list.nodelist(); }
/** * Use an XPath string to select a nodelist. * 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 A NodeIterator, should never be null. * * @throws TransformerException */ public NodeList selectNodeList( Node contextNode, String str, Node namespaceNode) throws TransformerException { // Execute the XPath, and have it return the result XObject list = eval(contextNode, str, namespaceNode); // Return a NodeList. return list.nodelist(); }
private Object getResultAsType( XObject resultObject, QName returnType ) throws javax.xml.transform.TransformerException { // XPathConstants.STRING if ( returnType.equals( XPathConstants.STRING ) ) { return resultObject.str(); } // XPathConstants.NUMBER if ( returnType.equals( XPathConstants.NUMBER ) ) { return new Double ( resultObject.num()); } // XPathConstants.BOOLEAN if ( returnType.equals( XPathConstants.BOOLEAN ) ) { return new Boolean( resultObject.bool()); } // XPathConstants.NODESET ---ORdered, UNOrdered??? if ( returnType.equals( XPathConstants.NODESET ) ) { return resultObject.nodelist(); } // XPathConstants.NODE if ( returnType.equals( XPathConstants.NODE ) ) { NodeIterator ni = resultObject.nodeset(); //Return the first node, or null return ni.nextNode(); } String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE, new Object[] { returnType.toString()}); throw new IllegalArgumentException( fmsg ); }
return resultObject.nodelist();
private Object getResultAsType( XObject resultObject, QName returnType ) throws javax.xml.transform.TransformerException { // XPathConstants.STRING if ( returnType.equals( XPathConstants.STRING ) ) { return resultObject.str(); } // XPathConstants.NUMBER if ( returnType.equals( XPathConstants.NUMBER ) ) { return new Double ( resultObject.num()); } // XPathConstants.BOOLEAN if ( returnType.equals( XPathConstants.BOOLEAN ) ) { return resultObject.bool() ? Boolean.TRUE : Boolean.FALSE; } // XPathConstants.NODESET ---ORdered, UNOrdered??? if ( returnType.equals( XPathConstants.NODESET ) ) { return resultObject.nodelist(); } // XPathConstants.NODE if ( returnType.equals( XPathConstants.NODE ) ) { NodeIterator ni = resultObject.nodeset(); //Return the first node, or null return ni.nextNode(); } String fmsg = XSLMessages.createXPATHMessage( XPATHErrorResources.ER_UNSUPPORTED_RETURN_TYPE, new Object[] { returnType.toString()}); throw new IllegalArgumentException( fmsg ); }
return resultObject.nodelist();
return xobj.nodelist();
(m_resultType == ORDERED_NODE_SNAPSHOT_TYPE)) { try { m_list = m_resultObj.nodelist(); } catch (TransformerException te) {
/** * Converts an XObject to a node iterator XPathResult. */ protected Result convertNodeIterator(XObject xo, short type) throws javax.xml.transform.TransformerException { return new Result(xo.nodelist(), type); }
/** * Converts an XObject to a node iterator XPathResult. */ protected Result convertNodeIterator(XObject xo, short type) throws javax.xml.transform.TransformerException { return new Result(xo.nodelist(), type); }
/** * Converts an XObject to a single node XPathResult. */ protected Result convertSingleNode(XObject xo, short type) throws javax.xml.transform.TransformerException { return new Result(xo.nodelist().item(0), type); }
/** * Converts an XObject to a single node XPathResult. */ protected Result convertSingleNode(XObject xo, short type) throws javax.xml.transform.TransformerException { return new Result(xo.nodelist().item(0), type); }
/** * Converts an XObject to a node iterator XPathResult. */ protected Result convertNodeIterator(XObject xo, short type) throws javax.xml.transform.TransformerException { return new Result(xo.nodelist(), type); }
/** * Extract NodeList using expression * @param document {@link Document} * @param xPathExpression XPath expression * @return {@link NodeList} * @throws TransformerException when the internally used xpath engine fails */ public static NodeList selectNodeList(Document document, String xPathExpression) throws TransformerException { XObject xObject = XPathAPI.eval(document, xPathExpression, getPrefixResolver(document)); return xObject.nodelist(); }
protected NodeList getNodeList(final Document doc, final String xpath) throws TransformerException { final DefaultPrefixResolver prefixResolver = new DefaultPrefixResolver(doc.getNodeType() == Node.DOCUMENT_NODE ? doc.getDocumentElement() : doc); return getXPathAPI().eval(doc, xpath, prefixResolver).nodelist(); }
protected NodeList getNodeList(final Document doc, final String xpath) throws TransformerException { final DefaultPrefixResolver prefixResolver = new DefaultPrefixResolver( doc.getNodeType() == Node.DOCUMENT_NODE ? doc .getDocumentElement() : doc); return getXPathAPI().eval(doc, xpath, prefixResolver).nodelist(); }
protected NodeList getNodeList(final Document doc, final String xpath) throws TransformerException { final DefaultPrefixResolver prefixResolver = new DefaultPrefixResolver(doc.getNodeType() == Node.DOCUMENT_NODE ? doc.getDocumentElement() : doc); return getXPathAPI().eval(doc, xpath, prefixResolver).nodelist(); }
protected NodeList getNodeList(final Document doc, final String xpath) throws TransformerException { final DefaultPrefixResolver prefixResolver = new DefaultPrefixResolver( doc.getNodeType() == Node.DOCUMENT_NODE ? doc .getDocumentElement() : doc); return getXPathAPI().eval(doc, xpath, prefixResolver).nodelist(); }