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 11099 - clarify that "element's tag name" and "attribute's name" are qualified name
Summary: clarify that "element's tag name" and "attribute's name" are qualified name
Status: RESOLVED FIXED
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: Other other
: P3 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL: http://www.whatwg.org/specs/web-apps/...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-19 22:16 UTC by contributor
Modified: 2011-08-04 05:15 UTC (History)
7 users (show)

See Also:


Attachments

Description contributor 2010-10-19 22:16:01 UTC
Section: http://www.whatwg.org/specs/web-apps/current-work/#serializing-html-fragments

Comment:
clarify that "element's tag name" and "attribute's name" are qualified name

Posted from: 85.227.159.236
Comment 1 Henri Sivonen 2010-10-20 08:04:45 UTC
I think we shouldn't use the qualified name for xlink:href and stuff. Instead we should hard-code the xlink prefix to the serializer and emit "xlink:" followed by the localName for attributes in the XLink namespace.

Likewise, I think elements should serialize using the localName even if someone has managed to inject a prefix into the DOM.

Rationale on both counts: Parseability using the HTML parsing algorithm.
Comment 2 Cameron McCormack 2010-10-20 21:00:26 UTC
Agreed wrt xlink namespace attributes.  (I guess it doesn't matter for xml and xmlns namespaces, since they're required to use the given prefixes anyway.)

For other elements and attributes with a prefix, I don't really have an opinion.
Comment 3 Anne 2010-10-22 10:30:52 UTC
Then you have to deal with the situation where the element has used the xlink prefix for something else.
Comment 4 Henri Sivonen 2010-10-22 12:39:06 UTC
When serializing an HTML fragment, namespaces that aren't hard-wired to the HTML parsing algorithm will fail to round-trip anyway. Since they are going to break anyway, let's break them in the easiest way possible:
 1) If an attribute is in the XLink, XML or XMLNS namespace, prefix with xlink:, xml: or xmlns:
 2) Otherwise, always use the local name for both attributes and elements.
Comment 5 Simon Pieters 2010-10-22 12:50:21 UTC
xmlns="..." (in XMLNS namespace) would turn into xmlns:xmlns="..." with your proposal, but that's easy to fix.
Comment 6 Anne 2010-10-22 13:27:00 UTC
Also, that does not deal with <a x:test="1" y:test="2"> where x and y are bound to the "x" and "y" namespaces.
Comment 7 Henri Sivonen 2010-10-25 09:10:31 UTC
(In reply to comment #6)
> Also, that does not deal with <a x:test="1" y:test="2"> where x and y are bound
> to the "x" and "y" namespaces.

How do you propose those be dealt with? No matter what, you get a result that won't round-trip using the HTML parser.

I can see why what I proposed may not the the proper defense in depth properties, though. (Consider x:onclick with x bound to a namespace.)
Comment 8 Anne 2010-10-25 12:27:39 UTC
I think serializing using the qualified name and implementing SVG2's way of not needing namespaced attributes -- not sure if that is drafted yet -- is the way to go.
Comment 9 Cameron McCormack 2010-10-27 23:53:51 UTC
(In reply to comment #8)
> I think serializing using the qualified name and implementing SVG2's way of not
> needing namespaced attributes -- not sure if that is drafted yet -- is the way
> to go.

Nothing like that is drafted yet.  I think we should make {http://www.w3.org/1999/xlink}href attributes be serialized as "xlink:href", and worry about XLink-less href later when the SVG spec and implementations are supporting it.
Comment 10 Anne 2010-10-28 09:27:16 UTC
As I said, that creates theoretical problems for attributes that already have the xlink prefix. When setting SVG namespaced attributes in the HTML DOM just make sure they have the right prefix.
Comment 11 Cameron McCormack 2010-10-30 01:04:07 UTC
(In reply to comment #10)
> As I said, that creates theoretical problems for attributes that already have
> the xlink prefix. When setting SVG namespaced attributes in the HTML DOM just
> make sure they have the right prefix.

I don't think it should be required to use the right prefix when calling setAttributeNS.  I think many people do setAttribute("http://www.w3.org/1999/xlink", "href", "blah").

I don't think we should care too much about attributes set using the "xlink" prefix but not the XLink namespace; this issue is all about choosing where to break roundtripability.  My suggestion:

  * Known attributes in the XLink, XML and XMLNS namespaces get serialized
    such that they will round trip correctly when being parsed again -- i.e.,
    they will be serialized using "xlink", "xml" and "xmlns" prefixes.  (Except
    for xmlns="" of course.)

  * All other attributes in a namespace get serialized just as their qualified
    name.  If this qualified name matches one of the known attribute (regardless
    of whether it was specified on the element), then don't serialize it.
    (Optional design decision: If the qualified name had no prefix, also don't
    serialize it.  If not, then run the simply allow the possibility of
    identically named attributes when serializing an element.)

That seems simpler than defining a way for the troublesome attributes to be serialized by munging their names somehow.
Comment 12 Cameron McCormack 2010-10-30 01:10:02 UTC
(In reply to comment #11)
> I don't think it should be required to use the right prefix when calling
> setAttributeNS.  I think many people do
> setAttribute("http://www.w3.org/1999/xlink", "href", "blah").

(They do setAttributeNS, that is.  In SVG content.)
Comment 13 Ian 'Hixie' Hickson 2010-12-27 23:46:43 UTC
I guess we could also just drop anything that isn't in a supported namespace.
Comment 14 Anne 2011-01-03 14:43:59 UTC
I suspect that would break stuff. Throwing data away also does not seem like a good idea.
Comment 15 Ian 'Hixie' Hickson 2011-01-06 22:38:56 UTC
We're going to be throwing away the namespace anyway.
Comment 16 Ian 'Hixie' Hickson 2011-01-06 22:57:54 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Partially Accepted
Change Description: see diff given below
Rationale:

I ended up doing a mixture of the proposals above.

If it's an element in the HTML, SVG, or MathML namespaces, then there's no prefix, regardless of the DOM. Otherwise, I just let the qualified name through and round-tripping will break.

If it's an attribute in the XML, XMLNS, or XLink namespaces, then there's the canonical prefix (with an exception for xmlns:xmlns=""). If there's no namespace, there's no prefix. Otherwise, I just let the qualified name through and round-tripping will break.

I didn't do anything to stop duplicate attributes from being output, or to stop namespace prefixes bound to non-canonical namespaces from stomping over the canonical mapping's namespace, etc.
Comment 17 contributor 2011-01-06 22:58:51 UTC
Checked in as WHATWG revision r5743.
Check-in comment: teach the fragment serialisation algorithm about namespaces
http://html5.org/tools/web-apps-tracker?from=5742&to=5743
Comment 18 Michael[tm] Smith 2011-08-04 05:15:37 UTC
mass-move component to LC1