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 29398 - [QT3] Base uri with parse-xml in fn-parse-xml-011
Summary: [QT3] Base uri with parse-xml in fn-parse-xml-011
Status: CLOSED WORKSFORME
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate 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: 2016-01-28 12:27 UTC by Abel Braaksma
Modified: 2016-03-22 09:37 UTC (History)
1 user (show)

See Also:


Attachments

Description Abel Braaksma 2016-01-28 12:27:02 UTC
This test uses the "empty" environment. The documentation says only that there is no context item in such case. fn:parse-xml takes the base uri from the static context, which is set to the static base uri of the test XML.

Result: this test, as I currently understand it, should *not* return the empty sequence, but an actual URI.
Comment 1 Michael Kay 2016-01-28 14:42:13 UTC
document-uri(X) is required to return a URI u such that doc(u) is X. It has nothing to do with base URI. I guess one could invent some algorithm whereby dynamically-generated documents have a unique document-uri generated, and this document-uri/document pair is dynamically added to the set of Available Documents in the dynamic context. This might just about be conformant, but it's certainly not the way things are intended to work. 

XDM §5.4 says "The dm:document-uri accessor returns the absolute URI of the resource from which the Document Node was constructed", and in this test case there is no such resource or URI, so document-uri() should be null/empty.
Comment 2 Abel Braaksma 2016-01-29 15:15:58 UTC
Maybe I'm missing something, but in the fn:parse-xml section in F&O we write:

<quote>
The Static Base URI property from the static context of the fn:parse-xml function call is used both as the base URI used by the XML parser to resolve relative entity references within the document, and as the base URI of the document node that is returned.
</quote>

Doesn't that mean that the base URI from the static context *becomes* the document URI of the returned document node?

Or are you suggesting we have a bug here and the spec is overspecifying something that ought not be set this way because here "document-uri(X) is required to return a URI u such that doc(u) is X" will clearly not hold?
Comment 3 Abel Braaksma 2016-01-29 15:22:30 UTC
In fact, I think we even make this specific, in F&O on fn:document-uri we way in a Note:

<quote>
In the case of a document node $D returned by the fn:doc function, or a document node at the root of a tree containing a node returned by the fn:collection function, it will always be true that either fn:document-uri($D) returns the empty sequence, or that the following expression is true: fn:doc(fn:document-uri($D)) is $D. It is ·implementation-defined· whether this guarantee also holds for document nodes obtained by other means, for example a document node passed as the initial context node of a query or transformation.
</quote>

So: "It is ·implementation-defined· whether this guarantee also holds for document nodes obtained by other means".

But that does not answer whether the description of fn:parse-xml makes it mandatory or not, or implementation-defined to set this "resource URI".
Comment 4 Michael Kay 2016-01-29 17:26:25 UTC
The base URI of a node plays no part in determining its document URI.

Many documents can have the same base URI, and frequently do. It is not possible for two distinct documents to have the same document URI.
Comment 5 Abel Braaksma 2016-01-30 03:35:05 UTC
I think I see it now, I was confusing the document-uri with the base-uri in the spec texts. That said, we do say that whatever the document-uri is in this case is implementation-defined:

<quote>
It is ·implementation-defined· whether this guarantee also holds for document nodes obtained by other means, for example a document node passed as the initial context node of a query or transformation.
</quote>

So, an implementation could, for instance, use a base-uri equal to the base uri of the static context and (may) add some kind of uniqueness (say, generate-id($doc), or whatever) to create an identifiable and unique document-uri.

I don't agree however that "It is not possible for two distinct documents to have the same document URI.", simply because I believe the spec says otherwise, see quote above and in comment#3.

Perhaps that particular Note is not specific enough?
Comment 6 Michael Kay 2016-01-30 09:34:22 UTC
>I don't agree however that "It is not possible for two distinct documents to
have the same document URI."

We guarantee that document-uri(D) = "X" implies doc("X") is D, and we guarantee that two calls on doc with the same argument deliver the same document. These guarantee cannot be met if there are two documents D and E such that document-uri(D) = document-uri(E) and not(D is E).
Comment 7 Abel Braaksma 2016-01-30 21:55:10 UTC
(In reply to Michael Kay from comment #6)
> We guarantee that document-uri(D) = "X" implies doc("X") is D, and we
> guarantee that two calls on doc with the same argument deliver the same
> document. These guarantee cannot be met if there are two documents D and E
> such that document-uri(D) = document-uri(E) and not(D is E).

If so (and don't get me wrong, I understand your reasoning and it makes sense), we should say so, because we now say something different in the spec.

Section 2.6 fn:document-uri makes an explicit exception for documents not retrieved through fn:doc or fn:collection (see comment#3).

Section 14.6.1 fn:doc allows leniency at user option, or allows FODC0003 to be raised if the deterministic guarantee does not hold if such an option is not available.
Comment 8 O'Neil Delpratt 2016-03-04 10:52:15 UTC
I am requested that this bug be added to the agenda
Comment 9 Abel Braaksma 2016-03-08 17:50:17 UTC
As discussed at today's telcon, changing this bug to a spec bug.
Comment 10 Abel Braaksma 2016-03-15 16:22:31 UTC
As discussed at today's telcon, we came to the conclusion that fn:parse-xml MUST normatively return a document with absent document-uri, as is written in the current version of the spec.

On the perceived discrepancy with fn:document-uri: the fn:document-uri MUST return the empty sequence if the document-uri is absent (as per the data model and the document-uri accessor).

Conclusion: both test and spec are sound, no action needed.