<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>4763</bug_id>
          
          <creation_ts>2007-06-26 13:12:41 +0000</creation_ts>
          <short_desc>1.0.3dev: K2-InScopePrefixesFunc-12</short_desc>
          <delta_ts>2007-07-17 13:13:47 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Query Test Suite</product>
          <component>XML Query Test Suite</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows NT</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tim Mills">tim</reporter>
          <assigned_to name="Frans Englich">frans.englich</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>15607</commentid>
    <comment_count>0</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-06-26 13:12:41 +0000</bug_when>
    <thetext>The expected result for:

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

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

element {QName(&quot;&quot;, &quot;a&quot;)} {}

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

&lt;a xmlns=&quot;&quot; /&gt;

Since xmlns=&quot;&quot; removes a namespace binding, this only leaves the prefix &quot;xml&quot; 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 &quot;http://www.example.com/&quot;;
let $i := element e
{
    element {QName(&quot;&quot;, &quot;a&quot;)}                                {},
    element {QName(&quot;http://www.example.com/&quot;, &quot;b&quot;)}         {},
    element {QName(&quot;http://www.example.com/Second&quot;, &quot;c&quot;)}   {}
}
return (count(in-scope-prefixes($i)),
        count(in-scope-prefixes(exactly-one($i/*[namespace-uri() eq &quot;&quot;]))),
        count(in-scope-prefixes(exactly-one($i/b))),
        count(in-scope-prefixes(exactly-one($i/*[namespace-uri() eq &quot;http://www.
example.com/Second&quot;]))),
        $i)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15633</commentid>
    <comment_count>1</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2007-06-27 09:20:15 +0000</bug_when>
    <thetext>I have this problem that I forget things after I&apos;ve finished it -- and that clearly doesn&apos;t work for exotic topics like namespaces!

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

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

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:

&quot;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).&quot; and then continues to say:

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

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

I&apos;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:

&lt;e xmlns=&quot;http://example.com/&quot;&gt;
    {element {QName(&quot;&quot;, &quot;a&quot;)} {}}
&lt;/e&gt;

how would the result be &lt;e xmlns=&quot;http://example.com/&quot;&gt;&lt;a xmlns=&quot;&quot;/&gt;&lt;/e&gt;, without a binding for a&apos;s empty namespace?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15635</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2007-06-27 12:26:06 +0000</bug_when>
    <thetext>Saxon 8.9.0.4 gives the answer 1, which I believe is correct.

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

&gt;how would the result be &lt;e xmlns=&quot;http://example.com/&quot;&gt;&lt;a xmlns=&quot;&quot;/&gt;&lt;/e&gt;,
without a binding for a&apos;s empty namespace?

Thinking it terms of namespace nodes, which I prefer, &lt;a&gt; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15803</commentid>
    <comment_count>3</comment_count>
    <who name="Frans Englich">frans.englich</who>
    <bug_when>2007-07-13 12:20:44 +0000</bug_when>
    <thetext>Fixed in CVS, XQTS_current.zip is updated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>15833</commentid>
    <comment_count>4</comment_count>
    <who name="Tim Mills">tim</who>
    <bug_when>2007-07-17 13:13:47 +0000</bug_when>
    <thetext>Thanks.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>