[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Abandon the (mistaken) belief that XML attributesprovide "
On Sat, Mar 19, 2011 at 3:54 PM, Costello, Roger L. <costello@mitre.org> wrote: > However, the XML specification makes no such claim about attributes providing "metadata". This is what the XML specification says: > with due respect to W3C specs, that doesn't preclude you encoding metadata inside attributes ... I think the lack of a statement probably reflects that it was best left implied what you do with attributes instead of parochially instruct. > Attributes are used to associate name-value pairs with elements. yes correct, this is a good definition ... but doesn't mean you can't do foolish things like put escaped markup into an attribute ... when teaching this stuff I find its good to also go through the rules of atomization whenever speaking about attributes, it gives a flavor of what else can go inside of an attribute. > Thus, attributes don't provide data about an element's content. Attributes don't provide metadata. I think its far too literal to interpret the lack of an explicit statement to mean 'dont' > Attributes are purely a syntactic construct. unsure what you mean here, attributes are part of the Infoset and other data models so in that sense its not purely syntax but yes we could call all of XML as purely syntactic (after a few pints). > If you abandon the belief that attributes provide metadata then it frees you to create XML designs based on the capabilities of the applications you use. > instead of stating absolutes I will provide a few follow on statements; * proximity of metadata is pretty important, e.g. an attribute on an element is pretty close together and implies its saying something about the element and can be a useful container for such metadata. You could just as easily encode metadata as a nested element but I can think up some markup structures where having attributes encode this stuff provides better performance then having to step into every element and examine a child node (yes I would hope some processors optimize these kind of things away) * XML is generalist in nature, which is why we have things like RDF which makes much more explicit statements about how to relate data in terms of semantics (and metadata) ... that doesn't mean you can't make a home brew XML markup language to use attributes to relate metadata * I see this as a variant of the permathread 'elements vs attributes' e.g. 'attributes vs everything else' ... there is no conclusion to be made here as for best practice, I tend to use attributes in terms of preserving some state information about the element (and enclosed data) and typically the values will come from a constrained list of values or well known range (like dates) others may disagree. Jim Fuller
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|