[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: document()-function, using 2 arguments

Subject: Re: document()-function, using 2 arguments
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 05 Apr 2000 23:45:43 -0400
xsl document function uri
At 00/04/05 16:33 +0200, michael gruber wrote:
> Recall also that if you do not supply a second argument to the document()
> function then the a relative first argument value is resolved relative to
> the stylesheet node's base URI (hence, relative to the subdirectory in
> which the stylesheet is found).  If you do supply a second argument to the
> document() function, a relative first argument is resolved relative to the
> base URI of the node in the supplied second argument.
>

Here I have problems...
I think when not supplying a second argument the relative first argument s
resolved relative to the base URI of itself.

But in your sentence the word "itself" could be ambiguous: are you talking of the stylesheet file or the entity in which the stylesheet node is found for the instruction being executed?


In my answer I specified "the stylesheet node's base URI" ... hence I am talking about the node of the instruction which uses the document function.

When your node of the first argument is part of an external entity  its
base-URI is the directory where this entity is physically stored, and that's
the place where saxon / xt
are looking for the file...

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.


When you want the style's destination as second argument it's done by
document($mynode, document('')).
(I've read in the spec once again, and I think it's right)

I respectfully disagree with your conclusion. I'm assuming you are speaking above of trying to get at the base URI of the original stylesheet file at processor invocation time. But the embedded document() function above itself does not have a second argument, so the node returned is the root node of the entity in which the document() function is being called ... hence it still returns the base URI of the same entity of the above expression.


To illustrate my understanding, please consider my example below. XT is being invoked with the test1.xsl stylesheet from the test1 subdirectory. This includes test2.xsl which happens to be in a sibling directory named test2. Both directories contain a file named "test.xml". The test reveals that all calls using either no second argument or a second argument using the document('') function as you describe above return information from the subdirectory in which the document() function is being executed. Only in the last case where the source tree node is supplied does the function refer to the original directory. I do not believe you can reference the root of the initially invoked stylesheet file using an expression executed in a referenced stylesheet file.

As said: saxon and xt do so, xalan doesn't.
Xalan always looks at the base-URI of the first argument...

I have not tried to experiment with the base URI of the first argument as I understand that to be relevant ... the first argument is evaluated to be a string.


I hope this helps.

............ Ken


T:\ftemp\test1>type test.xml <?xml version="1.0"?> <test> This is test.xml from the test1 directory. </test> T:\ftemp\test1>type ..\test2\test.xml <?xml version="1.0"?> <test> This is test.xml from the test2 directory. </test> T:\ftemp\test1>type test1.xsl <?xml version="1.0"?><!--filename.xsl--> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ken="ken" version="1.0">

<ken:data>
  The file being accessed is test1.xsl.
</ken:data>

<xsl:include href="../test2/test2.xsl"/>

<xsl:template match="/">
  <xsl:call-template name="test2"/>
</xsl:template>

</xsl:stylesheet>

T:\ftemp\test1>type ..\test2\test2.xsl
<?xml version="1.0"?><!--filename.xsl-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:ken="ken"
                version="1.0">

<ken:data>
  The file being accessed is test2.xsl.
</ken:data>

<xsl:template name="test2">
  <xsl:value-of select="document('')//ken:data"/>
  <xsl:value-of select="document('test.xml')"/>
  <xsl:value-of select="document('test.xml', document(''))"/>
  <xsl:value-of select="document('test.xml',.)"/>
</xsl:template>

</xsl:stylesheet>

T:\ftemp\test1>xt test1.xsl test1.xsl
<?xml version="1.0" encoding="utf-8"?>

The file being accessed is test2.xsl.

This is test.xml from the test2 directory.

This is test.xml from the test2 directory.

This is test.xml from the test1 directory.


-- G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995) Web site: XSL/XML/DSSSL/SGML services, training, libraries, products. Practical Transformation Using XSLT and XPath ISBN 1-894049-04-7 Next instructor-led training: 2000-05-02,2000-05-11/12,2000-05-15, - 2000-06-12,2000-06-13,2001-01-27


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



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.