RE: Advice please on XML: attributes and namespaces

By way of closure of this thread, you can see the response at

http://lists.w3.org/Archives/Public/xml-editor/2011JulSep/0002


 

paul

 

From: www-tag-request@w3.org [mailto:www-tag-request@w3.org] On Behalf Of Grosso, Paul
Sent: Friday, 2011 July 01 9:47
To: Misha.Wolf@thomsonreuters.com; www-tag@w3.org
Cc: mdirector@iptc.org
Subject: RE: Advice please on XML: attributes and namespaces

 

Apologies, I should have mentioned to send it to xml-editor@w3.org.

 

paul

 

From: Misha.Wolf@thomsonreuters.com [mailto:Misha.Wolf@thomsonreuters.com] 
Sent: Friday, 2011 July 01 9:42
To: Grosso, Paul; www-tag@w3.org
Cc: mdirector@iptc.org
Subject: RE: Advice please on XML: attributes and namespaces

 

Hi Paul,

 

Where should I send the question?  I mailed public-xml-core-wg@w3.org on June 27 but my mail bounced L

 

Thanks,

Misha

 

 

From: www-tag-request@w3.org [mailto:www-tag-request@w3.org] On Behalf Of Grosso, Paul
Sent: 01 July 2011 15:17
To: Wolf, Misha (M Content Mktpl); www-tag@w3.org
Cc: mdirector@iptc.org
Subject: RE: Advice please on XML: attributes and namespaces

 

You could ask the W3C XML Core WG which is the working group responsible for maintenance of the XML Recommendations.  We would be happy to explain in detail what the XML specifications say and how they are unambiguous.  (Briefly, there is a difference between in-scope namespace declarations and namespaces themselves as applied to elements and attributes; but if asked, the XML Core WG will provide a complete explanation.)

 

Paul, presently speaking only for myself, but Co-chair of the XML Core WG

 

From: www-tag-request@w3.org [mailto:www-tag-request@w3.org] On Behalf Of Misha.Wolf@thomsonreuters.com
Sent: Friday, 2011 July 01 8:23
To: www-tag@w3.org
Cc: mdirector@iptc.org
Subject: Advice please on XML: attributes and namespaces

 

 

 

From: iptc-news-architecture-dev@yahoogroups.com [mailto:iptc-news-architecture-dev@yahoogroups.com] On Behalf Of Michael Steidl (IPTC)
Sent: 27 June 2011 12:10
To: iptc-news-architecture-dev@yahoogroups.com
Subject: [IPTC-NAR-dev] XML: attributes and namespaces - no clear solution

 

 

This posting refers to the discussion on the NAR-dev conference call last Friday, 24 June. The issue was: do attributes inherit the namespace of its element and this way also default namespaces?

 

After some searching my findings are:

 

** [1] is the standard document of the W3C and it speaks about Applying Namespaces to Elements and Attributes (chapter 6) :

- 6.1 Namespace scoping:

“ The scope of a namespace declaration declaring a prefix extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner declarations with the same NSAttName part. In the case of an empty tag, the scope is the tag itself.

Such a namespace declaration applies to all element and attribute names within its scope whose prefix matches that specified in the declaration.”

With this example:

<?xml version="1.0"?>

<html:html xmlns:html='http://www.w3.org/1999/xhtml'>

  <html:head><html:title>Frobnostication</html:title></html:head>

  <html:body><html:p>Moved to 

    <html:a href='http://frob.example.com'>here.</html:a></html:p></html:body>

</html:html>

 

- 6.2 Namespace defaulting

“The scope of a default namespace declaration extends from the beginning of the start-tag in which it appears to the end of the corresponding end-tag, excluding the scope of any inner default namespace declarations. In the case of an empty tag, the scope is the tag itself.

A default namespace declaration applies to all unprefixed element names within its scope. Default namespace declarations do not apply directly to attribute names; the interpretation of unprefixed attributes is determined by the element on which they appear.”

 

This leaves open what “determined by the element” exactly means – what we discussed last Friday: does the attribute inherit the element’s namespace – or not.

The next paragraph tells:

“ .... The namespace name for an unprefixed attribute name always has no value. ...”

 

... hm, this does not explain what “determined by the element” exactly means (Btw: the Errata document for this document says no errata exist ...). And there is no note available for the example above explaining if the  @href pertains to the html: namespace or not.

 

** So I started to google for views on that issue:

* The German  page (but not the one in English) about XML namespaces talks explicitly about attributes [2] – in short: as attributes are not a child node of an element they never inherit its namespace, if one wants to apply a namespace the corresponding prefix has to be applied.

* A website with “Articles and tutorials about XML-technology” [3] says about this issue: “An attribute is not considered a child of its parent element. An attribute never inherits the namespace of its parent element.”

* A VB tutorial about XML namespaces asserts the same [4]

* The only contradiction I found is on Stackoverflow [5]

“There's a reason that most XML vocabularies use non-namespaced attributes:

When your elements have a namespace and those elements have attributes, then there can be no confusion: the attributes belong to your element, which belongs to your namespace. Adding a namespace prefix to the attributes would just make everything more verbose.

So why do namespaced attributes exist?

Because some vocabularies do useful work with mostly attributes, and can do this when mixed in with other vocabularies.”

 

Conclusion: 

-          W3C does not define how default namespaces apply to attributes in a straightforward way

-          It is not fully clear if an attribute of a namespaced element interits its namespace.

-          Published views on that matter lean towards “does not inherit” – but not unambiguously 

 

What’s next: asking one of the editors of this document – Tim Bray or Henry Thompson?

 

Michael

 

[1] http://www.w3.org/TR/xml-names/ 

[2] http://de.wikipedia.org/wiki/Namensraum_%28XML%29#Attribute 

[3] http://www.xmlplease.com/attributexmlns 

[4] http://www.developerfusion.com/article/3720/understanding-xml-namespaces/6/ 

[5] http://stackoverflow.com/questions/41561/xml-namespaces-and-attributes 

 

Michael Steidl

Managing Director of the IPTC [mdirector@iptc.org]

International Press Telecommunications Council 
Web: www.iptc.org <http://www.iptc.org/>  - on Twitter @IPTC <http://www.twitter.com/IPTC> 

Business office address: 

20 Garrick Street, London WC2E 9BT, United Kingdom

Registered in England, company no 101096

 

 

__._,_.___

 

Your email settings: Individual Email|Traditional 
Change settings via the Web <http://groups.yahoo.com/group/iptc-news-architecture-dev/join;_ylc=X3oDMTJnYzU2Nms3BF9TAzk3NDc2NTkwBGdycElkAzE0MzMwMDkyBGdycHNwSWQDMTcwNjAzMDM4OQRzZWMDZnRyBHNsawNzdG5ncwRzdGltZQMxMzA5MTcyOTky>  (Yahoo! ID required) 
Change settings via email: Switch delivery to Daily Digest <mailto:iptc-news-architecture-dev-digest@yahoogroups.com?subject=Email%20Delivery:%20Digest>  | Switch to Fully Featured <mailto:iptc-news-architecture-dev-fullfeatured@yahoogroups.com?subject=Change%20Delivery%20Format:%20Fully%20Featured>  
Visit Your Group <http://groups.yahoo.com/group/iptc-news-architecture-dev;_ylc=X3oDMTJlaTZwM3RpBF9TAzk3NDc2NTkwBGdycElkAzE0MzMwMDkyBGdycHNwSWQDMTcwNjAzMDM4OQRzZWMDZnRyBHNsawNocGYEc3RpbWUDMTMwOTE3Mjk5Mg--> | Yahoo! Groups Terms of Use <http://docs.yahoo.com/info/terms/> | Unsubscribe <mailto:iptc-news-architecture-dev-unsubscribe@yahoogroups.com?subject=Unsubscribe> 

 

__,_._,___


This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.


This email was sent to you by Thomson Reuters, the global news and information company. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Thomson Reuters.

Received on Wednesday, 10 August 2011 16:20:37 UTC