[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Abandon the (mistaken) belief that XML attributesprovide "metadata" and set yourself free to explore capability-based designs
- From: James Fuller <james.fuller.2007@gmail.com>
- To: "Costello, Roger L." <costello@mitre.org>
- Date: Sat, 19 Mar 2011 16:53:55 +0100
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]