Another view of XML schema attributes vs. elements

Another way to look at whether you should add information as an attribute or a child element while designing an XML schema element is whether you are talking about an IS-A or a HAS-A relationship.

Attributes are great for IS-A relationships -- "I am an element with ID='20121101-i1' or "I am an element for the Dublin Core (METS MDTYPE='DC')".

Child elements are great for HAS-A relationships -- "I have several groups of files" or "I have binary and XML data for a file".

Leave a comment

About Mark Leighton Fisher

user-pic Perl/CPAN user since 1992.