Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


RE: XML Schema question: A equivalent for attributes?

From: "G. Ken Holman" <gkholman@----------------.--->
To: <xmlschema-dev@--.--->
Date: 8/28/2009 2:00:00 PM
At 2009-08-28 15:13 +0200, Simon Cox wrote:
>Else just use elements.
>Why does XML have the choice of element or attribute, anyway ;-)

Of course you can coerce any attribute value into an element, but I 
like having the distinction between containment and attachment.  Thus 
there is no problem distinguishing that which is content of an 
element from that which is about the element as a whole.  When some 
child elements are used to talk about the element as a whole and some 
child elements are used for information contained by the element, 
processing the information may not be different but understanding the 
relationships between information may be very different.

Of course if you want a structured attribute you are obliged to 
coerce that information into a child element (a good example here is 
<xsl:sort>).  So they aren't symmetrical in that regard.

And then not all schema languages treat attributes as first-class 
constructs like elements (RELAX-NG is good in doing so, for example, 
modeling a choice between an element and an attribute, or basing the 
complete structure of an element on different attribute values, or 
from the original post declaring an exclusive choice between 
attributes).  So if you can't use RELAX-NG then there are restrictions.

Robin Cover has collected various opinions about this:

   http://xml.coverpages.org/elementsAndAttrs.html

There is no "correct way of thinking" in this regard .... horses for 
courses ... and I still find some students who shy away completely 
from attributes and think everything should be done as elements.

I think it is an important distinction.

. . . . . . . . . . . . Ken


--
Interested in these classes?  http://www.CraneSoftwrights.com/x/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman@C...
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/x/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent