This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 10109 - [XSLT 2.0] fn:document function does not define what to do when base-node has no base URI
Summary: [XSLT 2.0] fn:document function does not define what to do when base-node has...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 2.0 (show other bugs)
Version: 2nd Edition Recommendation
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-08 12:12 UTC by Oliver Hallam
Modified: 2011-03-24 15:56 UTC (History)
0 users

See Also:


Attachments

Description Oliver Hallam 2010-07-08 12:12:16 UTC
Consider the following snippet:

<xsl:variable name="foo" type="text()">
  <xsl:text>text</xsl:text>
</xsl:variable>
<xsl:value-of select="document("relative.xml", $foo)" />


The specification says:

For an item in $uri-sequence that is an instance of xs:string, xs:anyURI, or xs:untypedAtomic, the value is cast to xs:anyURI. If the resulting URI reference is an absolute URI reference then it is used as is. If it is a relative URI reference, then it is resolved against the base URI of $base-node if supplied, or against the base URI from the static context otherwise (this will usually be the base URI of the stylesheet module). A relative URI reference is resolved against a base URI using the rules defined in [RFC3986].

In this case resolving the URI against the base URI of $base-node does not technically make sense - what does it mean to resolve a URI against a URI that doesn't exist?  Similarly the node could be passed in from the outside world and have a relative base URI.  Resolving against this does not give an absolute URI.
Comment 1 Oliver Hallam 2010-07-08 12:13:23 UTC
A similar undefined case is:

<xsl:variable name="foo" type="text()">
  <xsl:text>relative-uri</xsl:text>
</xsl:variable>
<xsl:value-of select="document($foo)" />
Comment 2 Michael Kay 2010-07-08 14:05:50 UTC
You're right that there are some nodes, for example parentless text nodes, that have no base URI. (In practice, there are whole documents that have no base URI because they are parsed from an anonymous input stream, but I'm not sure the specs acknowledge that case.)

We're had the debate about base URIs being relative before, and I don't recall the outcome. We're very casual about using the term "relative URI", but technically, a relative reference is not a URI. (And it's not just us: I see XML Base says "The terms base URI and relative URI are used in this specification as they are defined in [RFC 3986]." - but the term "relative URI" is explicitly discouraged in RFC 3986!). My understanding is that the base URI of a node is always an absolute URI.
Comment 3 Oliver Hallam 2010-07-08 16:47:56 UTC
You're right about the case of relative URIs - we have code that ensures that any node that touches the query processor does not have a relative base URI.

The case of an empty URI is still a problem though.
Comment 4 Michael Kay 2010-09-30 17:32:25 UTC
The Working Group decided that it should indeed be a dynamic error if the second parameter is passed and is a node with no base URI. I don't think we need to say anything here about the base URI being absolute.
Comment 5 Michael Kay 2011-03-24 15:09:02 UTC
This change has been applied to the spec. Oliver, can you close please?
Comment 6 Oliver Hallam 2011-03-24 15:56:14 UTC
I agree with this fix and am marking the bug CLOSED.