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 6807 - [FO] ambiguity in fn:namespace-uri-for-prefix
Summary: [FO] ambiguity in fn:namespace-uri-for-prefix
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 1.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: 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: 2009-04-13 19:39 UTC by Andrew Eisenberg
Modified: 2009-07-20 20:15 UTC (History)
1 user (show)

See Also:


Attachments

Description Andrew Eisenberg 2009-04-13 19:39:47 UTC
Bug 5703, reported against XQTS and closed last year, suggested that the correct response for

namespace-uri-for-prefix('', $in-xml)

was a zero-length string, where there is no default namespace in the in-scope namespaces of $in-xml.


In 11.2.5 fn:namespace-uri-for-prefix we say,

"If $element has an in-scope namespace whose namespace prefix is equal to $prefix, it returns the namespace URI of that namespace. If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace. Otherwise, it returns the empty sequence."


Where there is no default namespace, one could imagine returning either an empty sequence or a zero-length string as the result.

Michael Kay has suggested that specifying the result as the zero-length string would be consistent with namespace-uri and namespace-uri-from-QName.
Comment 1 Michael Kay 2009-04-14 08:14:13 UTC
I agree this should be clarified. I suggest:

* If $element has an in-scope namespace whose namespace prefix is equal to $prefix, the function returns the namespace URI of that namespace. 

* If $prefix is the zero-length string or the empty sequence, the function returns the namespace URI of the default namespace for $element if there is one, or the zero-length string otherwise 

* In all other cases, the function returns the empty sequence.
Comment 2 Michael Kay 2009-04-28 12:35:06 UTC
Investigation shows that different implementors have indeed interpreted this differently: some return "", some ().

In favour of "":

* this means that a return result of () always means the prefix is not available for use

* the prefix "" in this situation means "no namespace", and in other functions such as namespace-uri(), or namespace-uri-from-QName(), "no namespace" is denoted by "".

* This intepretation means that a redundant "xmlns=''" declaration has no effect, which is desirable, since it has no meaning.

* this is what the spec currently says:

"If $element has an in-scope namespace whose namespace prefix is equal to $prefix..." - not applicable, it doesn't.

"If $prefix is the zero-length string ..., it returns the namespace URI of the default (unnamed) namespace. - the condition is satisfied, so the only question is "what is the namespace URI of the default (unnamed) namespace?" In other methods, it is always "".

"Otherwise, it returns the empty sequence." - not applicable, we don't get this far.

Michael Kay

Comment 3 Michael Kay 2009-06-30 09:17:04 UTC
A decision on this was recorded in the minutes on 28 April:

http://lists.w3.org/Archives/Member/w3c-xsl-query/2009Apr/0069.html (member-only link)

The decision was to return a zero-length string.

An erratum will be drafted against the "second edition" spec.
Comment 4 Jim Melton 2009-07-03 19:43:23 UTC
I am marking this RESOLVED FIXED because WG has made the decision. (The editor will implement the solution on his own timetable.) If you're satisfied with this resolution, please mark the bug CLOSED.