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 20340 - [XT3TS] element-0306
Summary: [XT3TS] element-0306
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XSLT 3.0 Test Suite (show other bugs)
Version: Working drafts
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Abel Braaksma
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-11 13:59 UTC by Tim Mills
Modified: 2014-06-10 13:41 UTC (History)
2 users (show)

See Also:


Attachments

Description Tim Mills 2012-12-11 13:59:00 UTC
I agreed with the previous XML output, but not all the new assertions.  Are they correct?
Comment 1 Michael Kay 2012-12-11 14:21:41 UTC
I had a lot of trouble with this test because of the problems retaining precise namespace information when you round-trip through serialization and parsing. In the course of conversion I discovered some paths that weren't being tested, so the new test is actually more extensive than the old. By expressing it as assertions against the result tree, with no serialization and parsing involved, I think we get a much clearer picture of exactly what the result tree is supposed to look like. I spent a lot of time on it and I believe it's correct, but of course it's open to challenge. One of the benefits of splitting it into 20 or 30 assertions is that we can have a focused debate on which ones are open to dispute.
Comment 2 Tim Mills 2012-12-11 15:02:49 UTC
Here goes...

"If the newly constructed node is an element node, and if namespaces are inherited, then each namespace node of the newly constructed element (including any produced as a result of the namespace fixup process) is copied to each descendant element of the newly constructed element, unless that element or an intermediate element already has a namespace node with the same name (or absence of a name) or that descendant element or an intermediate element is in no namespace and the namespace node has no name."

Going inside out, we have

<dogsbody/> [[ fun easy "http://www.dummy_ns.com" xml ]]

This is then copied with namespace inheritance.

<IT_Specialist> [[ "http://www.all.com" xml ]]
  <dogsbody/> [[ fun easy "http://www.dummy_ns.com" xml ]]
</IT_Specialist>

Then we have:

<IT_Architect /> [[ "http://www.dummy_ns.com" xml ]]

<Business_Analyst /> { xml }

These then get copied when constructing profession without namespace inheritance.

<profession> [[ "http://www.dummy_ns.com" xml ]]
  <IT_Architect /> [[ "http://www.dummy_ns.com" xml ]]
  <IT_Specialist> [[ "http://www.all.com" xml ]]
    <dogsbody /> [[ fun easy "http://www.dummy_ns.com" xml ]]
  </IT_Specialist>
  <Business_Analyst/> { xml }
</profession>

Finally, these get copied when constructing out with namespace inheritance.

<out> [[ fun easy xml ]]
  <profession> [[ fun easy "http://www.dummy_ns.com" xml ]]
    <IT_Architect /> [[ fun easy "http://www.dummy_ns.com" xml ]]
    <IT_Specialist> [[ fun easy "http://www.all.com" xml ]]
      <dogsbody /> [[ fun easy "http://www.dummy_ns.com" xml ]]
    </IT_Specialist>
    <Business_Analyst/> { fun easy xml }
  </profession>
</out>
 
Do you agree with the above?
Comment 3 Michael Kay 2012-12-11 20:21:51 UTC
I have sinking feeling that you are right.
Comment 4 Abel Braaksma 2013-11-27 22:19:49 UTC
We too were struggling understanding the full depth of this test. Our current output generates the following:

<?xml version="1.0" encoding="UTF-8"?>
<out xmlns:easy="http://www.easyJobs.com" xmlns:fun="http://www.funJobs.com">
    <profession xmlns="http://www.dummy_ns.com">
        <IT_Architect/>
        <IT_Specialist xmlns="http://www.all.com">
            <dogsbody xmlns="http://www.dummy_ns.com"/>
        </IT_Specialist>
        <Business_Analyst xmlns=""/>
    </profession>
</out>

Looking at Jim Mills' comment #2, I belief this is correct, taking into account the following snippet of the spec: "unless that element or an intermediate element already has a namespace node with the same name (or absence of a name)". In the above output, each element node has, or has not, the namespaces as defined in comment #2. 

If we take all assertions currently in that test and run it against that output, we get the following:

true: /out/namespace::* = "http://www.funJobs.com"
true: /out/namespace::* = "http://www.easyJobs.com"
true: /out/namespace::* = "http://www.w3.org/XML/1998/namespace"
true: count(/out/namespace::*) = 3
true: /out/*:profession/namespace::* = "http://www.funJobs.com"
true: /out/*:profession/namespace::* = "http://www.easyJobs.com"
true: /out/*:profession/namespace::* = "http://www.dummy_ns.com"
true: /out/*:profession/namespace::* = "http://www.w3.org/XML/1998/namespace"
true: count(/out/*:profession/namespace::*) = 4
true: /out/*:profession/*:IT_Architect/namespace::* = "http://www.w3.org/XML/1998/namespace"
true: /out/*:profession/*:IT_Architect/namespace::* = "http://www.dummy_ns.com"
false: count(/out/*:profession/*:IT_Architect/namespace::*) = 2
true: /out/*:profession/*:IT_Specialist/namespace::* = "http://www.w3.org/XML/1998/namespace"
true: /out/*:profession/*:IT_Specialist/namespace::* = "http://www.all.com"
false: count(/out/*:profession/*:IT_Specialist/namespace::*) = 2
true: /out/*:profession/*:IT_Specialist/*:dogsbody/namespace::* = "http://www.w3.org/XML/1998/namespace"
true: /out/*:profession/*:IT_Specialist/*:dogsbody/namespace::* = "http://www.funJobs.com"
true: /out/*:profession/*:IT_Specialist/*:dogsbody/namespace::* = "http://www.easyJobs.com"
true: /out/*:profession/*:IT_Specialist/*:dogsbody/namespace::* = "http://www.dummy_ns.com"
true: count(/out/*:profession/*:IT_Specialist/*:dogsbody/namespace::*) = 4
true: /out/*:profession/Business_Analyst/namespace::* = "http://www.w3.org/XML/1998/namespace"
false: count(/out/*:profession/Business_Analyst/namespace::*) = 1

The three ones failing are:

- false: count(/out/*:profession/*:IT_Architect/namespace::*) = 2
  this seems indeed incorrect. It should be 4 (easy, fun, dummy_ns and xml)

- false: count(/out/*:profession/*:IT_Specialist/namespace::*) = 2
  same as the previous. The count should be 4 here.

- false: count(/out/*:profession/Business_Analyst/namespace::*) = 1
  count should be 3 (easy, fun, xml)


If you agree with my assertions, I'd like to go ahead and push the changes to the repository, so that we can close this bug.
Comment 5 Tim Mills 2013-12-09 09:35:12 UTC
Thanks - I agree.
Comment 6 Abel Braaksma 2014-05-23 15:39:34 UTC
There is consensus.
Rev#441 contains changeset that fixes this bug, marking it as resolved.
Comment 7 Michael Kay 2014-06-04 10:07:45 UTC
The same problem affects test xml-version-026, which reads:

<xsl:template match="/">
  <doc xmlns:a="http://a/">
    <chap xsl:inherit-namespaces="no">
      <para/>
      <para xmlns:a=""/>
    </chap>
  </doc>
</xsl:template>

The doc element effectively has inherit-namespaces="yes" and this causes the xmlns:a namespace to be present on both para elements; the inherit-namespaces="no" on the intermediate level has no effect.

I'm changing the test to add inherit-namespaces="no" on the doc element.
Comment 8 Tim Mills 2014-06-10 13:41:59 UTC
Thanks.