Liquid Studio Documentation
Tutorials / W3C XSD Schema Tutorial / XSD Tutorial - Part 2 - Conventions & Recommendations
In This Topic
    XSD Tutorial - Part 2 - Conventions & Recommendations
    In This Topic
    This section covers conventions and recommendations, when designing your schemas.

    When to use Elements or Attributes

    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:

    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 Element Content

    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.