Closed
Bug 590467
Opened 16 years ago
Closed 16 years ago
document(<relative uri>) doesn't translate into an absolute uri relative to the stylesheet but to the xml file
Categories
(Core :: XSLT, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: cyrilapan, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0b4) Gecko/20100818 Firefox/4.0b4
Build Identifier: Mozilla/5.0 (Windows NT 6.1; rv:2.0b4) Gecko/20100818 Firefox/4.0b4
When an xml file references an xslt stylesheet and this stylesheet has some relative uri passed to a document() function, the function doesn't resolve the relative uri based on the stylesheet uri but to the xml file uri.
But I understand from the specs (at http://www.w3.org/TR/1999/REC-xslt-19991116#document) that any relative uri should be relative to the stylesheet uri. This is the way it's processed in Opera.
Reproducible: Always
Steps to Reproduce:
1. Open http://towerofbabel.free.fr/stroke%20order/%E6%BC%A2%E5%AD%97/%E6%95%B4%E5%AD%97/%E4%B8%89.svg
2. Open http://towerofbabel.free.fr/stroke%20order/%E6%BC%A2%E5%AD%97/%E6%95%B4%E5%AD%97/%E5%BF%83.svg
Actual Results:
With step 1, you will see the svg image in Firefox, not in Opera 10.61.
With step 2, you won't see the svg image in Firefox, but will see it in Opera 10.61
Expected Results:
With step 1, you shouldn't see the svg image in Firefox.
With step 2, you should see the svg image in Firefox.
The svg image in step 1 refers to external documents with uri based on the xml file uri.
The svg image in step 2 refers to external documents with uri based on the stylesheet uri.
Although both svg images use the <use> tag, this tag is transformed by the stylesheet using the document() function, so browsers doesn't have to actually interpret the <use> tags.
The spec says:
"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."
And above that it 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"
These two rules together mean that if you pass a nodeset as a single argument, uris should be resolved relative to the nodes in that nodeset.
So we are doing the right thing here.
Status: UNCONFIRMED → RESOLVED
Closed: 16 years ago
Resolution: --- → INVALID
Comment 2•16 years ago
|
||
The section about the base URI says: "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.", so I don't think I agree.
Status: RESOLVED → REOPENED
Ever confirmed: true
Resolution: INVALID → ---
This is the paragraph cited by Peter Van der Beken that got me to submit this bug.
As for this paragraph:
"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"
I find it really hard to understand: it's talking about when the document() function has only one argument, but then the result must be computed with a second argument...it's really misleading.
Oops, I've just understand the "misleading paragraph".
It indeed says the relative uri must be resolved from the argument nodeset.
But the other section says it must "defaults to the node in the stylesheet that contains" the document() function. In my case, it's a <xsl:variable> tag, which is part of the stylesheet and not part of the xml file.
So it seems like the specs have 2 sections contradicting each other...
I don't think there is ambiguity or self contradiction.
There are three rules laid out by the spec about how to interpret the arguments:
A) 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
B) 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.
C) When the first argument to the document function is not a node-set, the first argument is converted to a string as if by a call to the string function
There are further
i) 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
ii) 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
Your call to document() in your stylesheet looks like:
document(@xlink:href)
The @xlink:href part is an expression that returns a nodeset (containing 0 or 1 nodes).
Since this is a nodeset the transformation in A is applied. The result is, if your nodeset contains 1 node the result of
document(string(@xlink:href), @xlink:href)
(If the nodeset contains 0 nodes, the result is the empty nodeset as it's a union of 0 document() calls).
If the first argument is a relative uri, i) says that the node in the second argument should be used to calculate the base uri.
I guess you could argue that it's ambiguous if the rule in ii) is applied before the rule in A) or not. However if ii) was applied first, then the rule in A) couldn't be true, i.e. the replacement wouldn't be equivalent. So I don't think that is a correct interpretation.
Further, by applying A) first, the document() allows uri-references to be resolved against the uri of the document that they appear in. This clearly makes a lot more sense.
So I still contend that this bug is clearly INVALID.
Comment 6•16 years ago
|
||
Ah, hmm, I missed that this passes a nodeset as the first (and only) argument, I guess I agree with INVALID after all.
Done and done.
cyrilapan: If you want this clarified in the spec, I suggest you contact the XSL-WG at W3C. However I think at this point XSLT1 is no longer maintained since XSLT2 has been out for so long.
Status: REOPENED → RESOLVED
Closed: 16 years ago → 16 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•