This section covers conventions and recommendations when designing your schemas.
There is often some confusion over when to use an element or an attribute. Some people say that elements describe data and attributes describe the meta data. Another way to look at it is that attributes are used for small pieces of data such as order id's, but really, it is personal taste that dictates when to use an attribute. Generally it is best to use a child element if the information feels like data. Some of the problems with using attributes are:
Attributes cannot contain multiple values (child elements can) Attributes are not easily expandable (to incorporate future changes to the schema) Attributes cannot describe structures (child elements can) lf you use attributes as containers for data, you end up with documents that are difficult to read and maintain. Try to use elements to describe data. What I am trying to say here is that metadata (data about data) should be stored as attributes, and that data itself should be stored as elements.
Mixed content is something you should try to avoid as much as possible. It is used heavily on the web in the form of XHTML, but that has many limitations. It is difficult to parse and it can lead to unforeseen complexity in the resulting data. XML Data Binding has limitations associated with it making it difficult to manipulate such documents.
Element and Attributes should use UCC camel case, eg (PostalAddress), avoid hyphens, spaces or other syntax. element, attribute, and type names. Exceptions should be well known within your business area eg ID (Identifier), and POS (Point of Sale). Type'. eg AddressType, USAddressType. CustomerName, should be Name within the sub element Customer. complexTypes or simpleTypes for types that are likely to be re-used. If the structure only exists in one place, define it inline with an anonymous complexType. elements if the element is capable of being the root element in an XML document. xml (defined in XML standard) xmlns (defined in Namespaces in XML standard) xs http://www.w3.org/2001/XMLSchema xsi http://www.w3.org/2001/XMLSchema-instance targetNamespace in your schema. This better identifies your schema and can make things easier to modularize and re-use. elementFormDefault="qualified" in the schema element of your schema. This makes qualifying the namespaces in the resulting XML simpler (if not more verbose). | You must Sign In to use this message board. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||