xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mdela...@us.britannica.com
Subject RE: Attribute and Element
Date Thu, 18 May 2000 22:37:54 GMT
Also, if you're XML document needs to be high performance, attributes are
much more efficient.  The main drawback of an attribute is that it is a
simple string; it should never be long, and it can never contain elements.
If you think you may reuse the concept of "Price" in other contexts or want
to assign child elements, it makes more sense to define it as an element.

> -----Original Message-----
> From: Rob Wygand [mailto:rob@wygand.com]
> Sent: Thursday, May 18, 2000 5:07 PM
> To: general@xml.apache.org
> Subject: Re: Attribute and Element
> 
> 
> This is a cause of much debate and consternation for me. What I've
> generally decided is that the relationship come down to IS A 
> and HAS A.
> If the thing in question is an integral part of the object represented
> by the parent, then make it an attribute. However, if it's another
> seperate 'object' and the parent known owns it, then I make it a child
> node.
> 
> This is all still highly subjective, but I always try to think how I'd
> model this in an RDBMS and then use a similar scheme.
> 
> An example is...
> 
> <EmailMessage>
>   <Headers From="rob@wygand.com" 
>            To="foo@bar.com" 
>            Date="10-10-10T10:10:10Z"
>            Subjec"Hello, there foo"/>
>   <Body content_type="text/plain" content_encoding="7bit">
>      Test message!
>   </Body>
>   <Attachment content_type="image/gif" name="myhouse.jpg"
> content_encoding="base64">
>  
> AAlLJSLKFJLKFJSLJFLKSJFLSKJFLSKJFLKFJSLDJFLSJDFLKSJFLSJFLKSDJF
> SLKFJLFJSDLKJLSJFLS
>  
> LJSLKFJLKFJSLJFLKSJFLSKJFLSKJFLKFJSLDJFLSJDFLKSJFLSJFLKSDJFSLK
> FJLFJSDLKJLSJFLSAA0
>                                                                      
> [... etc ...]
>   </Attachment>
> </EmailMessage>
> 
> 
> Cheun N Chong wrote:
> >         The confusion I am having now is, should I put the Price (or
> > ValidBefore) as an attribute of the Ticket or put it as an 
> element under
> > the Ticket. What is the difference, and what is the benefits?
> >
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org
> 

Mime
View raw message