Bug 20261 - [SER30] Usability problem with XHTML 5.0 prefix stripping
Summary: [SER30] Usability problem with XHTML 5.0 prefix stripping
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Serialization 3.0 (show other bugs)
Version: Last Call drafts
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Henry Zongaro
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-06 09:21 UTC by Michael Kay
Modified: 2013-01-22 18:34 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Kay 2012-12-06 09:21:47 UTC
Bullet 4 in the second bullet list in section 6 states, inter alia:

It is a serialization error [err:SERE0020] if the element node has a namespace node for the default namespace whose value is not equal to the namespace URI of the element node.

This seems to imply that it is impossible to serialize the following perfectly reasonable document:

<html xmlns="http://www.w3.org/1999/xhtml">
   <head><title>Heading</title></head>
   <body>
     <div>
       <s:svg xmlns:s="http://www.w3.org/2000/svg" version="1.1">
          <s:circle cx="100" cy="50" r="40" stroke="black" 
              stroke-width="2" fill="red"/>
       </s:svg>
    </div>
   </body>
</html>

because the svg element violates this rule. Surely this is not intended?
Comment 1 Michael Kay 2012-12-06 09:35:04 UTC
A related problem: the rule also states "The serializer MUST serialize a default namespace declaration for the namespace, unless a default namespace declaration for the same namespace URI is already in scope for the element in the serialized result." but fails to say that this namespace declaration must be cancelled on any descendant elements that use a different default namespace or none.

I would propose solving these issues by describing the process differently. The XHTML 5.0 serializer should apply the following transformation to the result tree prior to serialization:

<xsl:template match="xhtml:* | svg:* | mathml:*">
  <xsl:element name="{local-name()}" namespace-uri="{namespace-uri()}">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates/>
  </xsl:element>
</xsl:template>
Comment 2 Henry Zongaro 2012-12-11 16:14:49 UTC
I think your proposed transformation looks reasonable at first glance.

Speaking for myself, of course, not the working groups.
Comment 3 Henry Zongaro 2013-01-14 10:59:40 UTC
Michael, at their joint teleconference of 18 December 2012,[1] the XSLT and XQuery Working Groups decided to revise the Serialization 3.0 document along the lines that you've proposed in comment #1.

As you were present when this decision was made, I trust you agree with it, and I will mark the bug as CLOSED.

[1] https://lists.w3.org/Archives/Member/w3c-xsl-query/2012Dec/0054.html
Comment 4 Henry Zongaro 2013-01-15 15:41:14 UTC
Michael, I have applied changes to the latest member-only Serialization 3.0 draft, primarily to section 6,[2] that I hope remedy this bug to your satisfaction.  I attempted to improve the description of stripping prefixes in prose and added an XSLT stylesheet that I hope is equivalent to that description.

If it satisfactorily resolves the issue, I will then create an equivalent XQuery expression.

I would be grateful if you could have a look.

These changes also fix the problem reported in the first comment of bug 20251.[3]

[2] https://www.w3.org/XML/Group/qtspecs/specifications/xslt-xquery-serialization-30/html/Overview.html#xhtml-output
[3] https://www.w3.org/Bugs/Public/show_bug.cgi?id=20251#c1
Comment 5 Michael Kay 2013-01-15 22:20:53 UTC
I suspect that in this template

  <xsl:template match="node()|@*|namespace::*">
    <xsl:copy>
      <xsl:apply-templates select="@*|namespace::*|node()"/>
    </xsl:copy>
  </xsl:template>

the xsl:copy should say copy-namespaces="no", as the whole point of the template is to be selective about which namespace nodes are copied.
Comment 6 Henry Zongaro 2013-01-16 14:57:09 UTC
Michael, thanks for spotting that omission.  My XSLT neurons have atrophied after a year of disuse!
Comment 7 Henry Zongaro 2013-01-22 18:34:29 UTC
Michael, I have updated the Serialization draft to add the "copy-namespaces" attribute to the xsl:copy, as you suggested.  I had also added an XQuery equivalent, but have since removed it, as directed by the XSLT and XQuery working groups in their joint teleconference of 22 January 2013.[4]

The latest internal draft of Serialization 3.0 contains these changes.

[4] https://lists.w3.org/Archives/Member/w3c-xsl-query/2013Jan/0073.html (Member-only link.)