You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xml.apache.org by Rob Wygand <ro...@wygand.com> on 2000/05/19 00:07:04 UTC

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">
 
AAlLJSLKFJLKFJSLJFLKSJFLSKJFLSKJFLKFJSLDJFLSJDFLKSJFLSJFLKSDJFSLKFJLFJSDLKJLSJFLS
 
LJSLKFJLKFJSLJFLKSJFLSKJFLSKJFLKFJSLDJFLSJDFLKSJFLSJFLKSDJFSLKFJLFJSDLKJLSJFLSAA0
                                                                     
[... 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?
>