Re: document()-function, using 2 arguments

Subject: Re: document()-function, using 2 arguments
From: michael gruber <gruberm@xxxxxx>
Date: Thu, 06 Apr 2000 23:15:50 +0200
Hai!

"G. Ken Holman" wrote:

> That is not my understanding of the recommendation.  The base URI of the
> first argument is not material.  Even if the first argument is a node, that
> node's base URI is not used as a base for resolution.  The first argument
> is converted to a simple string and the string has no base URI ... the
> *second* argument determines the base URI: if absent the base URI is that
> of the stylesheet node that is the instruction being executed, if present,
> the base URI is that of the first of the supplied nodes in the expression.

Specification (12.1) says:
"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."

Here we see three times the word "node". I think all of them mean that node (resp.
act. member of node-set) which is passed as argument.

In my understanding that means:
(Simplified but right  imho...)
if we have only one argument,
and that is a *node*(-set)
it's the same as calling the document function with two arguments:
First argument is a string (which was converted from the *node*'s value)
Second argument is the *node*.


Maybe I'm wrong but when I look at the following I think it is correct:
(or better said that are the results because of which i read the spec as I read
it)
(and -last comment- if I'm still / once again  wrong I'll stop here and sleep...)

michael


   document (test.xsl, test.xml)
         |
         |---- input (test.xml)
         |
         |---- ent (test.xml)


*******document\test.xml
<?xml version="1.0"?>
 <test>
   This is test.xml from the document directory.
 </test>
*********************

*******D:\TEST\document\input\test.xml

<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY testentity SYSTEM "../ent/test.xml" >
                ]>
<root>
 <node>test.xml</node>
 <test>
   This is test.xml from the input directory.
 </test>
 &testentity;
</root>
******************

*******D:\TEST\document\ent\test.xml
<ent>
 <node-enti>test.xml</node-enti>
 <test>
   This is test.xml from the enti directory.
 </test>
</ent>
****************************
*******document\test.xsl

<?xml version="1.0" ?>
<!DOCTYPE xsl:stylesheet>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

<xsl:template match="/">
<xsl:value-of select="document('test.xml')//test"/>
<xsl:value-of select="document(root/node)//test"/>
<xsl:value-of select="document(root/ent/node-enti)//test"/>
<xsl:value-of select="document(root/ent/node-enti, .)//test"/>
<xsl:value-of select="document('test.xml', document(''))//test"/>
<xsl:value-of select="document('test.xml',.)//test"/>
<xsl:value-of select="document('test.xml',root/ent/node)//test"/>
</xsl:template>

</xsl:stylesheet>
*******************

****D:\TEST\document>type result.txt
<?xml version="1.0" encoding="utf-8"?>

   This is test.xml from the document directory.
   This is test.xml from the input directory.                    <---!!!!!
   This is test.xml from the enti directory.                      <---!!!!!
   This is test.xml from the input directory.
   This is test.xml from the document directory.
   This is test.xml from the input directory.
   This is test.xml from the enti directory.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread