sboag       00/02/23 00:50:50

  Modified:    src/org/apache/xalan/xslt FuncDocument.java
  Log:
  Fixed the 2-arg version to only use the stylesheet tree when the given node 
is from the stylesheet.  Needs to be reviewed by Myriam.
  
  Revision  Changes    Path
  1.10      +29 -11    xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java
  
  Index: FuncDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/src/org/apache/xalan/xslt/FuncDocument.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- FuncDocument.java 2000/02/11 23:07:50     1.9
  +++ FuncDocument.java 2000/02/23 08:50:49     1.10
  @@ -66,6 +66,17 @@
   
   /**
    * Execute the Doc() function.
  + * 
  + * When the document function has exactly one argument and the argument 
  + * is a node-set, then the result is the union, for each node in the 
  + * argument node-set, of the result of calling the document function with 
  + * the first argument being the string-value of the node, and the second 
  + * argument being a node-set with the node as its only member. When the 
  + * document function has two arguments and the first argument is a node-set, 
  + * then the result is the union, for each node in the argument node-set, 
  + * of the result of calling the document function with the first argument 
  + * being the string-value of the node, and with the second argument being 
  + * the second argument passed to the document function.
    */
   public class FuncDocument extends Function
   {
  @@ -90,19 +101,24 @@
       String base = "";
       if(args.size() > 1)
       {
  +      // The URI reference may be relative. The base URI (see [3.2 Base 
URI]) 
  +      // of the node in the second argument node-set that is first in 
document 
  +      // order is used as the base URI for resolving the 
  +      // relative URI into an absolute URI. 
         XObject arg2 = (XObject)args.elementAt(1);
         if(XObject.CLASS_NODESET == arg2.getType())
         {
  -       /* Node baseNode = arg2.nodeset().item(0);
  +        Node baseNode = arg2.nodeset().item(0);
           Document baseDoc = (Node.DOCUMENT_NODE == baseNode.getNodeType()) ? 
                              (Document)baseNode : baseNode.getOwnerDocument();
           
           if(baseDoc instanceof Stylesheet)
  -          base = ((Stylesheet)baseDoc).getBaseIdentifier();
  +        {
  +          // base = ((Stylesheet)baseDoc).getBaseIdentifier();
  +          base = execContext.getNamespaceContext().getBaseIdentifier();   
  +        }
           else
             base = execContext.findURIFromDoc(baseDoc);
  -        */
  -         base = execContext.getNamespaceContext().getBaseIdentifier();       
         
         }
         else
         {
  @@ -112,13 +128,15 @@
       }
       else
       {
  -     /* Node stylesheetNode = (Node)execContext.getNamespaceContext(); // is 
this safe in this context??
  -      Document baseDoc = (Node.DOCUMENT_NODE == 
stylesheetNode.getNodeType()) ? 
  -                         (Document)stylesheetNode : 
stylesheetNode.getOwnerDocument();
  -      if(baseDoc instanceof Stylesheet)
  -        base = ((Stylesheet)baseDoc).getBaseIdentifier();
  -      else
  -        base = execContext.findURIFromDoc(baseDoc);*/
  +      // If the second argument is omitted, then it defaults to 
  +      // the node in the stylesheet that contains the expression that 
  +      // includes the call to the document function. Note that a 
  +      // zero-length URI reference is a reference to the document 
  +      // relative to which the URI reference is being resolved; thus 
  +      // document("") refers to the root node of the stylesheet; 
  +      // the tree representation of the stylesheet is exactly 
  +      // the same as if the XML document containing the stylesheet 
  +      // was the initial source document.
         base = execContext.getNamespaceContext().getBaseIdentifier();
       }
       XNodeSet nodes = new XNodeSet();
  
  
  

Reply via email to