[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: attribute order

what are attributes in oo
On Sun, 2005-05-08 at 09:25 -0700, Mukul Gandhi wrote:
> --- Uche Ogbuji <uche.ogbuji@f...> wrote:
> > It can be very dangerous thinking overall.  I've
> > seen numerous examples
> > of poor XML design because of too literal a
> > translation from OO
> > concepts.  Just for one example, see [1] for
> > discussion of confusion
> > that arises from the fact that most "object
> > references" in XML are
> > implicit.
> Now I realize, that mapping XML model(using element
> containership and attributes) to OO paradigm is not
> quite appropriate.. For trivial examples, we may do
> so. But we cannot generalize this correspondence.


> . I
> read your article [1]. Really a nice article.


> You have
> given an example to model a library inventory with
> XML.. I would like to say a bit about this XML
> structure you gave -
> <library>
>   <name>The XML Institute Public Library</name>
>   <books>
>     <book isbn="0764547607">
>       <title>The XML Bible, 2nd Edition</title>
>     </book>
>     <book isbn="0321150406">
>       <title>Effective XML</title>
>     </book>
>     <book isbn="1861005946">
>       <title>Beginning XSLT</title>
>     </book>
>   </books>
> </library>
> /library/books/book containership structure seems fine
> to me. name is a property of library (object), if we
> model a real world concept.

I think that "name" is a far more important propoerty than the
artificial abstraction "books".  But in the end that's why I admit int
the article it's a matter of judgment.

> . It could have been made a
> attribute instead of element (to me, having it as
> attribute will match the real world view better).

I think that's a bad idea for a couple of reasons:

1) It's really meant for people, not machines.  I prefer to use
attributes for metadata-like things with affinity towards machines
2) It forbids internal structure.  If after the initial design, it turns
out there is a library within whose name we really want to use
underlines/italics or such, we have to resort to hacks.

I almost always put names and titles in elements, rather than
attributes, for reasons I elaborate on in several of the articles in the
Principles of XML series.

Again, this is a good example of how XML modeling brings uo different
concerns from OO modeling.

> But
> here, I'll favour aesthetics than the OO thinking.. To
> me, "name" as a child element of "library" appeals
> more aesthetically. It also seems more tool friendly
> (like to an XML editor).. For e.g. if a description
> becomes too long (e.g. name) , making it an attribute
> is not quite readable. Also if there are chances of
> existence of newline in data, I'll prefer to make the
> information as element..
> So it seems to me now, that designing an XML document
> is also an art, than a pure science..

Of course it's an art.  But to be fair, so is OO modeling.  Science is
deterministic, but if you put 5 OO experts in 5 different rooms with the
same problem and had them come up with an OO design, you'd get 5
different results.

> > I think XML requires an entirely different mind-set
> > from objects.
> Yes.. Now I realize!

Yaaaay!  I do think that's a very important point of view to come to.  I
also came to XML from OO, and I still work in OO, and I've learned to
separate the two, to the benefit of both.

> I read your artcile [2] also.. Its nice too!

Thanks again.

> > [1] http://www-106.ibm.com/developerworks/xml/library/x-contain.html
> > [2] http://www.adtmag.com/article.asp?id=8596

Uche Ogbuji                               Fourthought, Inc.
http://uche.ogbuji.net                    http://fourthought.com
http://copia.ogbuji.net                   http://4Suite.org
Use CSS to display XML, part 2 - http://www-128.ibm.com/developerworks/edu/x-dw-x-xmlcss2-i.html
XML Output with 4Suite & Amara - http://www.xml.com/pub/a/2005/04/20/py-xml.html
Use XSLT to prepare XML for import into OpenOffice Calc - http://www.ibm.com/developerworks/xml/library/x-oocalc/
Schema standardization for top-down semantic transparency - http://www-128.ibm.com/developerworks/xml/library/x-think31.html


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.

Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.