W3C home > Mailing lists > Public > public-xsl-wg@w3.org > February 2016

Tests using document("")

From: Michael Kay <mike@saxonica.com>
Date: Wed, 3 Feb 2016 15:30:34 +0000
To: Public XSLWG <public-xsl-wg@w3.org>
Message-Id: <0144F524-AEAA-4E77-86B0-30929F3E6800@saxonica.com>
We have a number of tests (listed below) that assume that the expression document("") can be used to access the source code of the stylesheet. Now that we are moving to a package architecture that encourages the idea of executing stylesheets in a different environment from where they were compiled, this assumption becomes questionable: source code is not necessarily available at run-time.

We could handle this in a number of ways, e.g. by adding a dependency or by rewriting the tests to remove this assumption.

But it might be worth looking at exactly what the spec says on this.

The reason document("") works is that "" is a relative URI reference which is resolved against the static base URI to return the static base URI unchanged, and the static base URI is assumed to be the location of the source stylesheet.

We may well have other tests that assume static-base-uri() evaluates at run-time to the location of the source stylesheet - I just haven't found them yet. 

We have added a note to the definition of static-base-uri() in F+O to say: "
XQuery 3.0 and XSLT 3.0 give an implementation freedom to use different base URIs during the static analysis phase and the dynamic evaluation phase, that is, for compile-time and run-time resources respectively. In this situation, the fn:static-base-uri function should return a URI suitable for locating resources needed during dynamic evaluation.

But the assumption that static base URI corresponds to the source code is still pretty deeply embedded elsewhere, e.g. XSLT section 5.3.1 says "The static base URI is the base URI of the containing element in the stylesheet." 

Michael Kay

~/w3c/xslt30-test-B/tests/attr/mode/mode-0011.xsl:18:     <xsl:apply-templates select="document('')/*"/>
~/w3c/xslt30-test-B/tests/attr/select/select-5601.xsl:11:     <xsl:apply-templates select="document('')/*/xsl:template[@name=$whichtmplt]"/>
~/w3c/xslt30-test-B/tests/attr/select/select-5701.xsl:13:     <xsl:apply-templates select="document('')/*/xsl:template[@name=$whichtmplt]"/>
~/w3c/xslt30-test-B/tests/decl/function/function-1301.xsl:239:                     select="document('')/*/str-reverse-func:*[1]"/>
~/w3c/xslt30-test-B/tests/decl/variable/variable-0105.xsl:13:    <xsl:apply-templates select="document('')/*/test:*[1]">
~/w3c/xslt30-test-B/tests/decl/variable/variable-0114.xsl:17:    <xsl:apply-templates select="document('')/*/test:*[1]">
~/w3c/xslt30-test-B/tests/expr/expression/expression-0501.xsl:12:       <xsl:for-each select="document('')"> <!-- change the current node to confuse things -->
~/w3c/xslt30-test-B/tests/expr/expression/expression-1101.xsl:26:     <xsl:for-each select="document('')/key('city','France')">
~/w3c/xslt30-test-B/tests/fn/accessor/accessor-036.xsl:11:             <xslt:value-of select="ends-with(document-uri(document('')), 'accessor-036.xsl')"/>
~/w3c/xslt30-test-B/tests/fn/document/document-1003.xsl:7:     <!-- Purpose: When document('') refers to the root node of the stylesheet,
~/w3c/xslt30-test-B/tests/fn/document/document-1004.xsl:6:     <!-- Purpose: When document('') refers to the root node of the stylesheet,
~/w3c/xslt30-test-B/tests/fn/document/document-2005.xsl:8:       <xsl:copy-of select="document('')/*"/>
~/w3c/xslt30-test-B/tests/fn/document/document-2301.xsl:5:   <!-- Purpose: Use document('') to refer to the stylesheet, and have a local lookup table. -->
~/w3c/xslt30-test-B/tests/fn/document/document-2301.xsl:25:         <xsl:value-of select="document('')/xsl:stylesheet/months:name[@sequence=current()/@sequence]"/>
~/w3c/xslt30-test-B/tests/fn/key/key-043.xsl:35:       <xsl:for-each select="document('')">
~/w3c/xslt30-test-B/tests/fn/key/key-066.xsl:17:     <xsl:variable name="data" select="document('')/*/d:Footnote"/>
~/w3c/xslt30-test-B/tests/insn/copy/copy-1203.xsl:19:       <xsl:copy-of select="document('')/*/xsl:template[@name='qq']/node()" />
~/w3c/xslt30-test-B/tests/insn/sequence/sequence-0112.out:6:         <xsl:sequence select="document('')"/>
~/w3c/xslt30-test-B/tests/insn/sequence/sequence-0112.xsl:10:         <xsl:sequence select="document('')"/>
~/w3c/xslt30-test-B/tests/misc/bug/bug-2501.xsl:28:       <xsl:sort select="document('')//m:month[@name=current()/@month]/@value" 
~/w3c/xslt30-test-B/tests/type/namespace/namespace-4801.xsl:13:     <xsl:for-each select='document("")//ped:test'><xsl:copy/><xsl:text>&#010;</xsl:text></xsl:for-each>

Received on Wednesday, 3 February 2016 15:31:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:43:27 UTC