[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: document()-function, using 2 arguments
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. > 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
<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.
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|