XML Schema: Best Practices

Best Practices

* Use Venetian Blind Design over Russian Doll and Slami Slice Designs when possible
* Make targetNamespace the default namespace
* Make two identical copies of all your schemas:
– One with elementFormDefault=”qualified”
– One with elementFormDefault=”unqualified”
* Uniquely identify all schema components with the id attribute

<xsd:element name="elevation" type="xsd:integer" id="flight:aircraft:elevation"/>
<xsd:complexType name="publication" id="wrox:book:publication"/>

* Postpone binding decisions
* Create extensible schemas
– Use abstract type with type substitution
– Use <any>

<xsd:element name="other" minOccurs="0">
  <xsd:any namespace="##any" maxOccurs="2"/>
</xsd:element>

* When in doubt, use type, i.e. declare an item as a type instead of an element.
– A type can be reused in other elements.
* Favor composition over inheritance

References

* http://www.xfront.com/BestPracticesHomepage.html

This entry was posted in xml. Bookmark the permalink.