This is also an old issue of XML style.
I agree that mixed model is not desirable because it is more difficult
to parse and can lead to ambiguities.
You can put everything into elements as Andrew explains, but this also
makes XML's natural verbosity even worse.
A best practice and rule of thumb is to use attributes for things that
you could call "meta data", or in this case, "meta meta data" :-)
A typical case are things like types, styles, modes, etc. Information
that can help you interpret the real data inside the elements.
Using the HTML example again, think of the "src" attribute in an <img>,
or embedded CSS style attributes, or an elements id, or things like
that. Another way of thinking about this is: If you were to eliminate
all the tags from an XML document, you should get all the raw textual
information (You don't want to see the junk that tells you HOW to
interpret, render, etc that information).
These are rules of thumb, there are many cases where either way
(attributes or no attributes) would be accetable. That's when you use
your preferences, and personal tastes.
As for "the barriers to cross-walking XML", what are you using for XML
traversal that attributes make it hard to do? I'm mostly familiar with
XPath, and it presents no problems. (/element1/element2/@attrib)
BarZ
Houghton,Andrew wrote:
>>From: Metadata Object Description Schema List
>>[mailto:[log in to unmask]] On Behalf Of Karen Coyle
>>Sent: 22 July, 2005 13:24
>>To: [log in to unmask]
>>Subject: [MODS] Getting rid of attributes?
>>
>>.. would it be enough to make author and type sub-elements of
>>the topic elements, i.e.
>>
>> <mads xsi:schemaLocation="http://www.loc.gov/mads/mads.xsd">
>> <authority>
>> <topic>Computer programming
>> <authorityList>lcsh</authorityList>
>> </topic>
>> </authority>
>> <related>
>> <topic>Computers
>> <relatedType>broader</relatedType>
>> <authorityList>lcsh</authorityList>
>> </topic>
>> </related>
>>etc.
>>
>>And if that's all it would take, what is the downside of
>>using this style? Are there particular advantages to using
>>attributes vs. elements?
>
>
> What you have proposed is what is called a Mixed Model where you
> mix text and elements freely, like you do in HTML. I wouldn't
> recommend using a Mixed Model for any XML based grammar. However,
> you can turn any Mixed Model into regular model by the declaration
> of a few more elements. So your example might become:
>
> <mads xsi:schemaLocation="http://www.loc.gov/mads/mads.xsd">
> <authority>
> <topic>
> <label>Computer programming</label>
> <authorityList>lcsh</authorityList>
> </topic>
> </authority>
> <related>
> <topic>
> <label>Computers</label>
> <relatedType>broader</relatedType>
> <authorityList>lcsh</authorityList>
> </topic>
> </related>
> </mads>
>
> There is an upside to using element only based XML grammars in that
> you can put your XML grammar into RDF by using the striping method.
> So given my altered example, you could just wrap that XML with
> <rdf:RDF xmlns:rdf="..."> ... </rdf:RDF> thus <mads> becomes an RDF
> class.
>
> There is one issue with using attributes that you need to be aware of.
> Attribute values are normalized according to the XML specification,
> thus leading, trailing and multiple embedded spaces are collapsed and
> attribute values are not affected by xml:space attribute.
>
>
> Andy.
Internet Banda Ancha Todo el Dia por $u 490 por mes
Sin gastos adicionales - Sin ocupar su telefono
Y los primeros 4 meses 50% de descuento!
______________________________________________________
http://www.internet.com.uy - En Uruguay somos internet
|