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 11590 - Correct the expected result of test functx-fn-namespace-uri-for-prefix-all
Summary: Correct the expected result of test functx-fn-namespace-uri-for-prefix-all
Status: RESOLVED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: unspecified
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Benjamin Nguyen
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-22 15:55 UTC by Sorin Nasoi
Modified: 2011-07-19 14:15 UTC (History)
4 users (show)

See Also:


Attachments

Description Sorin Nasoi 2010-12-22 15:55:06 UTC
the expected result of test 'functx-fn-namespace-uri-for-prefix-all' has a space at the beginning that is not suppose to be there:

http://dev.w3.org/cvsweb/~checkout~/2006/xquery-test-suite/TestSuiteStagingArea/ExpectedTestResults/FunctX/functx-fn-namespace-uri-for-prefix/functx-fn-namespace-uri-for-prefix-all.txt?rev=1.1.1.1&content-type=text/plain
Comment 1 Benjamin Nguyen 2011-01-04 11:54:07 UTC
Correct, I will update the test result file.
Comment 2 Benjamin Nguyen 2011-01-07 11:33:06 UTC
Updated in the current CVS.
Comment 3 Sorin Nasoi 2011-01-07 17:46:53 UTC
The problem was fixed.
Comment 4 Oliver Hallam 2011-01-10 12:17:32 UTC
I disagree with the original commenter, the initial space in the result should be there, and is necessary; the test is now broken.

The first call to namespace-uri-for-prefix in the test takes the empty string as the first argument.  The specification for the function says:

If $prefix is the zero-length string or the empty sequence, it returns the namespace URI of the default (unnamed) namespace.

In this case, the default namespace is the empty string.

Thus the test returns the empty xs:anyURI followed by three more xs:anyURI values.
These are seperated with spaces when the result is serialized.  Hence the result requires a space at the start.
Comment 5 Sorin Nasoi 2011-01-12 00:15:38 UTC
Oliver Hallam is right in fact: the original expected result was correct, the change should be reverted.
Comment 6 Benjamin Nguyen 2011-01-12 10:26:55 UTC
I have changed to return the leading whitespace. I have marked the resolution as WONT FIX with regards to the initial bug report.
Comment 7 Andrew Eisenberg 2011-04-25 20:40:36 UTC
The XML Query WG confirmed the decision in Comment #6 at its Feb./March 2011 F2F meeting.

A simplified query for us to consider is:

namespace-uri-for-prefix('', <a/>)

The WG believes that this should return the empty string rather than the empty sequence.

Partly, this belief is supported by:

Section 11.2.4 fn:namespace-uri-from-QName

"If $arg is in no namespace, the zero-length xs:anyURI is returned."

Section 14.3 fn:namespace-uri

"... or if it is an element or attribute node whose expanded-QName (as determined by the dm:node-name accessor in the Section 5.11 node-name AccessorDM) is in no namespace, then the function returns the xs:anyURI corresponding to the zero-length string."


Section 11.2.5, fn:namespace-uri-for-prefix, of F&O says:

"If $prefix is the zero-length string or the empty sequence, it returns the
namespace URI of the default (unnamed) namespace."


The WG believes that the namespace URI of an element in no namespace could be clarified in the next version of XQuery and F&O.
Comment 8 Michael Kay 2011-04-25 21:37:03 UTC
I agree that the spec is confusing. There are two problems:

(a) The term "default (unnamed) namespace" is nonsense: every namespace has a namespace name. What is intended is "default namespace".

(b) The sentence "Otherwise, it returns the empty sequence." is preceded by two conditionals, and it's not clear which one the "otherwise" relates to. I believe the first is intended.

But I believe that the correct result for namespace-uri-for-prefix('', <a/>) is () rather than "". No element ever has an in-scope namespace that maps the prefix "" to the namespace URI "". The definition of the term "in-scope namespace" comes via XDM from the Infoset: see section 2 clause 7 of http://www.w3.org/TR/xml-infoset/#infoitem.element

<quote>
The set will include namespace items corresponding to all of the members of [namespace attributes],  except for any representing declarations of the form xmlns="" or xmlns:name="", which do not declare a namespace but rather undeclare the default namespace and prefixes.
</quote>

Because (in the absence of a default namespace) there is no in-scope namespace that provides a mapping for the prefix "", the following rule from fn:namespace-uri-for-prefix() takes effect: "Otherwise, it returns the empty sequence."

I have raised bug #12554 against the spec.
Comment 9 Andrew Eisenberg 2011-05-09 15:55:54 UTC
The XML Query and XSL WGs revisited the decision reported in Comment #7 at their May 3 teleconference. The WGs decided that both

namespace-uri-for-prefix('', <a/>)
and 
namespace-uri-for-prefix((), <a/>)

should return the empty sequence, agreeing with Mike's comment #8.


I have changed the result of functx-fn-namespace-uri-for-prefix-all as was originally requested, removing the leading space character.
Comment 10 Tim Mills 2011-05-23 16:26:00 UTC
In view of this clarification, does not test

K2-NamespaceURIForPrefixFunc-2

also need to be modified?


namespace-uri-for-prefix("", 
  exactly-one(<e xmlns="http://www.example.com/A" 
                 xmlns:A="http://www.example.com/C">
                <b xmlns:B="http://www.example.com/C" xmlns=""/>
              </e>/b)) eq ""
Comment 11 Andrew Eisenberg 2011-05-23 17:50:48 UTC
I've changed the result of K2-NamespaceURIForPrefixFunc-2 to be the empty sequence, represented in K2-NamespaceURIForPrefixFunc-2.txt as an empty file.

Tim, please close this bug if you agree with this change.
Comment 12 Tim Mills 2011-05-24 06:57:44 UTC
Confirmed fixed - thanks.
Comment 13 Sorin Nasoi 2011-07-14 16:26:16 UTC
In addition to the solution in comment #9, the result for test

http://dev.w3.org/2006/xquery-test-suite/TestSuiteStagingArea/Queries/XQuery/Functions/NodeFunc/NamespaceURIForPrefixFunc/fn-namespace-uri-for-prefix-4.xq

Has to be updated as well such that the expected result is the empty sequence.
Comment 14 Oliver Hallam 2011-07-18 10:56:06 UTC
(In reply to comment #13)
> In addition to the solution in comment #9, the result for test
> 
> http://dev.w3.org/2006/xquery-test-suite/TestSuiteStagingArea/Queries/XQuery/Functions/NodeFunc/NamespaceURIForPrefixFunc/fn-namespace-uri-for-prefix-4.xq
> 
> Has to be updated as well such that the expected result is the empty sequence.

Whilst fn:namespace-uri-for-prefix((),$var) returns the empty sequence,
fn:string(()) returns the empty string, and so I disagree.  This query should return the empty string.
Comment 15 Sorin Nasoi 2011-07-19 10:56:12 UTC
My fault is that I have said that "expected result should be empty sequence".
I should have said "expected result should be empty string".

Oliver's mistake is that he did not check the expected result of the test mentioned:

http://dev.w3.org/cvsweb/~checkout~/2006/xquery-test-suite/TestSuiteStagingArea/ExpectedTestResults/Functions/NodeFunc/NamespaceURIForPrefixFunc/fn-namespace-uri-for-prefix-4.txt?rev=1.1;content-type=text%2Fplain

that shows 'http://www.example.com/defaultspace' as stated in the correct expected result.

Please update the expected result to empty string.

Thanks,
Sorin
Comment 16 Michael Kay 2011-07-19 11:28:33 UTC
The current specification of fn:namespace-uri-for-prefix() at

http://www.w3.org/TR/xpath-functions-30/#func-namespace-uri-for-prefix

states: "If $prefix is the zero-length string or the empty sequence, then if $element has a default namespace (that is, a namespace node with no name), the function returns the namespace URI of the default namespace."

In test fn-namespace-uri-for-prefix-4 I believe that the <anElement> element does have a default namespace, whose namespace URI is "http://www.example.com/defaultspace", and that this is therefore the correct result of the query.
Comment 17 Sorin Nasoi 2011-07-19 11:37:02 UTC
@Michael Kay:
That is indeed what the spec says, but please look at the decision took on comment #9:

http://www.w3.org/Bugs/Public/show_bug.cgi?id=11590#c9

So, if the decision on comment #9 is wrong and the W3C spec is right,
then the expected result for 'functx-fn-namespace-uri-for-prefix-all' and 'K2-NamespaceURIForPrefixFunc-2' have to be changed back.

Otherwise the expected result for test 'fn-namespace-uri-for-prefix-4.xq' has to be updated to empty string, and also the W3C spec for 
http://www.w3.org/TR/xpath-functions-30/#func-namespace-uri-for-prefix 
has to reflect decision took on comment #9.
Comment 18 Michael Kay 2011-07-19 13:10:16 UTC
(In reply to comment #17)

In both the tests 'functx-fn-namespace-uri-for-prefix-all' and
'K2-NamespaceURIForPrefixFunc-2', the element in question has no default namespace. In test fn-namespace-uri-for-prefix-4 the element does have a default namespace. So the situations are not at all comparable.
Comment 19 Oliver Hallam 2011-07-19 13:18:59 UTC
I retract my previous comment - I didn't read the query carefully enough.

I agree with Mike on this one.