XML Schema best practice guideline
Found this XML Schema best practice guideline by David Stephenson.
Here is the summary.
1. General Meta requirements for XML schemas:
Understandable
Semantically complete
Constraining (i.e. validate)
Non-redundant
Reusable
Extensible
Non-modifying
Attributes vs. elements
There is no real consensus on when to use attributes or elements. Here are best practices to help you choose when writing your XML schema.
a. Use attributes for metadata about the parent element (foo is the parent element in the example above).
b. Use attributes for data that is semantically tied to the enclosing element.
c. Use elements for data that have a meaning separate from the enclosing element.
d. Use attributes when the value will be frequently present in order to improve the human readable form of an XML instance document or reduce its size.
e. If you don't know which to use, then use the element form (which is more extensible).
Always define elements globally. Elements within model groups (choice, sequence) should always use the ref= form and never the type= form.
No comments:
Post a Comment