How do you chose what to make #PCDATA and what to make an attribute? Here's a rule: If it is data meant to be displayed or processed by the application, use PCDATA. Only use tags for meta-data (data about the data). Here's an example: Suppose you have some text to be displayed by an application. If the user clicks on the text, you want the application to either make a noise or not. Do it like this:
<!DOCTYPE text
[
<!ELEMENT text #PCDATA>
<!ATTRIBUTE text beep (yes | no) #REQUIRED>
]
>
<text beep="yes">
Here is the text to be displayed. Whether the text beeps or
not is NOT displayed -- that's why it's an attribute.
</text>
References:
- http://www.oasis-open.org/cover/elementsAndAttrs.html
- http://java.sun.com/xml/docs/tutorial/overview/4_design.html
This page might be more accurately titled XmlPcDataVsXmlCdata
That guideline works fine if the xml is document based. More and more, xml is being used as a data structure. Our rule is that basic data types and typecodes are attributes, objects map map to elements. Elements that define relationships wrap subelements. IOW,
<facility unLocCode='us.fou' facilityId='cfs12'>
<facilityOperator>
<party code='party2.com'/>
</facilityOperator>
</facility>
CategoryXml CategoryPattern CategoryComparisons XmlPattern ExtensibleMarkupLanguage