sboag       01/06/22 07:54:30

  Modified:    java/src/org/apache/xpath Tag: Bxalan-j_2_2L XPathAPI.java
               java/src/org/apache/xpath/axes Tag: Bxalan-j_2_2L
                        LocPathIterator.java
  Log:
  In LocPathIterator#setCacheNodes, don't replace the current m_cachedNodes if
  it is non-null.  This fixes a bug with the NodeIterator/NodeSet
  adapters.
  
  In getDTMHandleFromNode, if a DTM has to be created, create
  it from the ownerDocument instead of the node argument.  I think
  this will avoid a lot of problems with node identity coming from
  extensions and the XPath API.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.12.2.1  +18 -25    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.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- XPathAPI.java     2001/06/15 17:54:18     1.12
  +++ XPathAPI.java     2001/06/22 14:54:26     1.12.2.1
  @@ -70,13 +70,11 @@
   import org.apache.xml.utils.PrefixResolverDefault;
   import org.apache.xml.utils.PrefixResolver;
   import org.apache.xpath.objects.XObject;
  -
   import org.apache.xml.dtm.DTM;
   import org.apache.xml.dtm.ref.DTMNodeIterator;
   import org.apache.xml.dtm.ref.DTMNodeList;
   import org.apache.xml.dtm.ref.DTMManagerDefault;
   
  -
   /**
    * The methods in this class are convenience methods into the
    * low-level XPath API.
  @@ -132,7 +130,7 @@
     /**
      *  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.
  @@ -148,7 +146,7 @@
     /**
      *  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.
  @@ -164,17 +162,14 @@
       // Execute the XPath, and have it return the result
       XObject list = eval(contextNode, str, namespaceNode);
   
  -    // Have the XObject return its result as a NodeSetDTM.
  -    // %TBD% Convert to DOM nodeset
  -             
  -    return new DTMNodeIterator(list.iter());
  -    
  +    // Have the XObject return its result as a NodeSetDTM.                
  +    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.
  @@ -190,7 +185,7 @@
     /**
      *  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.
  @@ -207,7 +202,7 @@
       XObject list = eval(contextNode, str, namespaceNode);
   
       // Return a NodeList.
  -    return new DTMNodeList(list.iter());
  +    return list.nodelist();
     }
   
     /**
  @@ -226,7 +221,8 @@
      *
      * @throws TransformerException
      */
  -  public static XObject eval(Node contextNode, String str) throws 
TransformerException
  +  public static XObject eval(Node contextNode, String str)
  +          throws TransformerException
     {
       return eval(contextNode, str, contextNode);
     }
  @@ -237,7 +233,7 @@
      *  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.
  @@ -274,10 +270,9 @@
       XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
   
       // Execute the XPath, and have it return the result
  -    // %TBD% Need to convert contextNode to a DTM node
  -//    return xpath.execute(xpathSupport, contextNode, prefixResolver);
  -    int ctxtNode;
  -             ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);
  +    // return xpath.execute(xpathSupport, contextNode, prefixResolver);
  +    int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);
  +
       return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
     }
   
  @@ -287,11 +282,11 @@
      *   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.
  -   *   @param prefixResolver Will be called if the parser encounters namespace 
  +   *   @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 org.apache.xpath.objects.XObject
  @@ -317,11 +312,9 @@
       XPath xpath = new XPath(str, null, prefixResolver, XPath.SELECT, null);
   
       // Execute the XPath, and have it return the result
  -    // %TBD% Need to convert contextNode to a DTM node
  -    // return xpath.execute(new XPathContext(), contextNode, prefixResolver);
  -             int ctxtNode;
  -             XPathContext xpathSupport = new XPathContext();
  -             ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);
  +    XPathContext xpathSupport = new XPathContext();
  +    int ctxtNode = xpathSupport.getDTMHandleFromNode(contextNode);
  +
       return xpath.execute(xpathSupport, ctxtNode, prefixResolver);
     }
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.26.2.1  +3 -0      xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java
  
  Index: LocPathIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/axes/LocPathIterator.java,v
  retrieving revision 1.26
  retrieving revision 1.26.2.1
  diff -u -r1.26 -r1.26.2.1
  --- LocPathIterator.java      2001/06/15 05:15:31     1.26
  +++ LocPathIterator.java      2001/06/22 14:54:29     1.26.2.1
  @@ -394,7 +394,10 @@
     {
   
       if (b)
  +    {
  +      if(null == m_cachedNodes)
         m_cachedNodes = new NodeSetDTM();
  +    }
       else
         m_cachedNodes = null;
     }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to