sboag       00/10/04 19:43:05

  Modified:    java/src/org/apache/xpath XPathAPI.java
  Log:
  Submitted by: Davanum Srinivas <[EMAIL PROTECTED]>
  Reviewed by: Scott Boag
  
  Make explicit selectNodeIterator and selectNodeList functions.
  
  Revision  Changes    Path
  1.3       +42 -6     xml-xalan/java/src/org/apache/xpath/XPathAPI.java
  
  Index: XPathAPI.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathAPI.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XPathAPI.java     2000/07/30 22:43:20     1.2
  +++ XPathAPI.java     2000/10/05 02:43:04     1.3
  @@ -60,6 +60,7 @@
   import org.w3c.dom.Node;
   import org.w3c.dom.Document;
   import org.w3c.dom.traversal.NodeIterator;
  +import org.w3c.dom.NodeList;
   import org.apache.xpath.XPathContext;
   import org.apache.xpath.XPath;
   import org.apache.xpath.compiler.XPathParser;
  @@ -108,7 +109,7 @@
       throws SAXException
     {
       // Have the XObject return its result as a NodeSet.
  -    NodeIterator nl = selectNodeList(contextNode, str, namespaceNode);
  +    NodeIterator nl = selectNodeIterator(contextNode, str, namespaceNode);
   
       // Return the first node, or null
       return nl.nextNode();
  @@ -120,12 +121,12 @@
      *
      * @param contextNode The node to start searching from.
      * @param str A valid XPath string.
  -   * @return A nodelist, should never be null.
  +   * @return A NodeIterator, should never be null.
      */
  -  public static NodeIterator selectNodeList(Node contextNode, String str)
  +  public static NodeIterator selectNodeIterator(Node contextNode, String str)
       throws SAXException
     {
  -    return selectNodeList(contextNode, str, contextNode);
  +    return selectNodeIterator(contextNode, str, contextNode);
     }
   
    /**
  @@ -135,9 +136,9 @@
      * @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 nodelist, should never be null.
  +   * @return A NodeIterator, should never be null.
      */
  -  public static NodeIterator selectNodeList(Node contextNode, String str, 
Node namespaceNode)
  +  public static NodeIterator selectNodeIterator(Node contextNode, String 
str, Node namespaceNode)
       throws SAXException
     {
       // Execute the XPath, and have it return the result
  @@ -147,6 +148,41 @@
       return list.nodeset();
   
     }
  +  
  + /**
  +   * 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.
  +   */
  +  public static NodeList selectNodeList(Node contextNode, String str)
  +    throws SAXException
  +  {
  +    return selectNodeList(contextNode, str, contextNode);
  +  }
  +
  + /**
  +   * 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.
  +   */
  +  public static NodeList selectNodeList(Node contextNode, String str, Node 
namespaceNode)
  +    throws SAXException
  +  {
  +    // Execute the XPath, and have it return the result
  +    XObject list = eval(contextNode, str, namespaceNode);
  +
  +    // Have the XObject return its result as a NodeSet.
  +    return (NodeList)list.nodeset();
  +
  +  }
  +
   
    /**
      * Evaluate XPath string to an XObject.  Using this method,
  
  
  

Reply via email to