On Jan 15, 2009, at 10:50 AM, Matt Jarvis wrote:
> Let me join the fray on this... I prefer SR's version since to me it
> is
> much more readable, which I always thought was (one of) the point of
> XML. Granted yours is much less verbose...
I wrote it in a more compact form, but you can format it to make is
just as readable if you wish.
I also don't understand why:
<sku>1234567</sku>
is more readable than:
sku="1234567"
> Do standard readers such as those built into browsers handle the
> "attribute-based XML"?
Yes, but the indentation chosen may not be the same.
The original design considered elements to be "things" and attributes
to be descriptors of those things. Sub-elements represent actual or
logical composition of the outer element. In this example, the sku is
not a separate thing, but an attribute of the item in question. In OO-
speak, elements are objects; if you wouldn't create an object in an OO
design, you shouldn't create an element in XML. Semantically,
attribute-based XML is much cleaner, and it maps more directly to
programming objects, but I recognize that, as usual, I'm in the
minority on this.
Check out the following two XML versions of the *exact same*
information. Obviously the first is more compact, but tell me why you
find the second more readable/ understandable/ natural.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version="1.0" encoding="UTF-8"?>
<team sport="baseball">
<player position="pitcher" throws="left" hits="left">Joe Doe</player>
<player position="catcher" throws="right" hits="both">Sam Smith</
player>
<player position="first base" throws="left" hits="left">Tom Thumb</
player>
<player position="second base" throws="right" hits="right">Frank
Beans</player>
...
</team>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
<?xml version="1.0" encoding="UTF-8"?>
<team>
<baseball>
<pitcher>
<player>
<name>Joe Doe</name>
<throws>left</throws>
<hits>left</hits>
</player>
</pitcher>
<catcher>
<player>
<name>Sam Smith</name>
<throws>right</throws>
<hits>both</hits>
</player>
</catcher>
<first_base>
<player>
<name>Tom Thumb</name>
<throws>left</throws>
<hits>left</hits>
</player>
</first_base>
<second_base>
<player>
<name>Frank Beans</name>
<throws>right</throws>
<hits>right</hits>
</player>
</second_base>
...
</baseball>
</team>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-- Ed Leafe
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.