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 4763 - 1.0.3dev: K2-InScopePrefixesFunc-12
Summary: 1.0.3dev: K2-InScopePrefixesFunc-12
Status: CLOSED FIXED
Alias: None
Product: XML Query Test Suite
Classification: Unclassified
Component: XML Query Test Suite (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Frans Englich
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-26 13:12 UTC by Tim Mills
Modified: 2007-07-17 13:13 UTC (History)
0 users

See Also:


Attachments

Description Tim Mills 2007-06-26 13:12:41 UTC
The expected result for:

        count(in-scope-prefixes(exactly-one($i/*[namespace-uri() eq ""]))),

in this query is 2.  I believe the answer should be one (corresponding to the predefined xml namespace).  As I understand it

element {QName("", "a")} {}

will create an element whose local name is "a" and with an empty namespace, effectively:

<a xmlns="" />

Since xmlns="" removes a namespace binding, this only leaves the prefix "xml" in scope, therefore the count is one.  Or am I mistaken?

(:*******************************************************:)
(: Test: K2-InScopePrefixesFunc-12                       :)
(: Written by: Frans Englich                             :)
(: Date: 2007-06-14T10:15:27+01:00                       :)
(: Purpose: Check the in-scope namespaces of different elements, constructed wit
h computed constructors. :)
(:*******************************************************:)
declare default element namespace "http://www.example.com/";
let $i := element e
{
    element {QName("", "a")}                                {},
    element {QName("http://www.example.com/", "b")}         {},
    element {QName("http://www.example.com/Second", "c")}   {}
}
return (count(in-scope-prefixes($i)),
        count(in-scope-prefixes(exactly-one($i/*[namespace-uri() eq ""]))),
        count(in-scope-prefixes(exactly-one($i/b))),
        count(in-scope-prefixes(exactly-one($i/*[namespace-uri() eq "http://www.
example.com/Second"]))),
        $i)
Comment 1 Frans Englich 2007-06-27 09:20:15 UTC
I have this problem that I forget things after I've finished it -- and that clearly doesn't work for exotic topics like namespaces!

A reduced, free-standing test case for what we're discussing is, I believe:

declare default element namespace "http://www.example.com/";
count(in-scope-prefixes(element {QName("", "a")} {}))

My implementation and Saxon 8.9.0.3J evaluates this to 2.

The second bullet point in 3.7.1.2 Namespace Declaration Attributes seems relevant, but contradictory. It says:

"This URI specifies the default element/type namespace of the constructor expression (overriding any existing default), and is added (with no prefix) to the in-scope namespaces of the constructed element (overriding any existing namespace binding with no prefix)." and then continues to say:

"If the namespace URI is a zero-length string, the default element/type namespace of the constructor expression is set to "none," and any no-prefix namespace binding is removed from the in-scope namespaces of the constructed element."

I guess it can be seen as an elaborated way of saying "if the prefix is empty and the namespace URI is empty, any existing binding to the empty prefix is removed"(not that I see how there's anything to remove for a newly created node).

I'm trying to reconstruct why Mike and I implemented it the way we did. The problem I see is how do you make sure, e.g when serializing, that a node actually gets the empty default namespace when being attached as a child with a non-empty namespace, without having an empty binding for the default namespace? That is, when serializing this:

<e xmlns="http://example.com/">
    {element {QName("", "a")} {}}
</e>

how would the result be <e xmlns="http://example.com/"><a xmlns=""/></e>, without a binding for a's empty namespace?
Comment 2 Michael Kay 2007-06-27 12:26:06 UTC
Saxon 8.9.0.4 gives the answer 1, which I believe is correct.

Bug http://sourceforge.net/tracker/index.php?func=detail&aid=1692131&group_id=29872&atid=397617 is relevant.

>how would the result be <e xmlns="http://example.com/"><a xmlns=""/></e>,
without a binding for a's empty namespace?

Thinking it terms of namespace nodes, which I prefer, <a> has only one namespace node, that for the XML namespace. The namespace undeclaration is added by the serializer when a child element lacks a namespace node|binding that is present on its parent.
Comment 3 Frans Englich 2007-07-13 12:20:44 UTC
Fixed in CVS, XQTS_current.zip is updated.
Comment 4 Tim Mills 2007-07-17 13:13:47 UTC
Thanks.