Altova Mailing List Archives


Re: XML Schemas: Best Practices

From: "Roger L. Costello" <costello@-----.--->
To: xml-dev@-----.---.---
Date: 10/12/2000 9:53:00 AM
Hi Folks,

I am very pleased with the discussion that we are getting on the
"element versus type" issue:

   "When should an item be declared as an element 
    versus when should an item be declared as a type?"

Below are two of the messages that have been received which address this
issue.  I see a pattern emerging from these messages.  Please let me
know if you see the same or a different pattern.

"Michael W. Ripley" wrote:
> 
> I think it's a matter of style.  As you showed in your examples, you
> can basically get done what needs to get done with either method.
> 
> My take on the style would be to use an element when all components
> of the element declaration will be reused and semantically the reuse
> will mean the same thing (Elevation, BostonElevation,
> FrankfurtElevation, SidneyElevation, etc.), and to use a type when
> the type definition will be reused for semantically different
> elements (e.g., a 'money' type definition that is reused for elements
> UnitPrice, Subtotal, ShippingAndHandling, Total, etc.).

Here's my interpretation of this message: 

- Declare an item as an element when the semantics of the item is to
remain unchanged (such as when you want to create synonyms/aliases). 

- Declare an item as a type when you want to associate multiple
different semantics to the item.

Paul Spencer wrote:
> 
> By re-using the address as a data type not an element, I have
> created two different address-type elements with different names. 
> This is a benefit of re-using types rather than elements. 

I interpret this to mean: the benefit of declaring an item as a type is
that the item can be associated with multiple different semantics.

> On the other hand, there are instances where you will always give 
> the resulting element the same name. 

I interpret this to mean: an item should be declared as an element when
the item is to always have the same semantics.

Summary:

"Here are guidelines for when to declare an item as an element versus
when to define it as a type: during the lifespan of an item, if it is to
be associated with multiple semantics then create a type definition. 
If, on the other hand, the item's semantics are to remain constant over
its lifetime, but multiple synonyms/aliases are to be used for the item
then declare it as an element."

Do you agree with these guidelines?  Perhaps these guidelines are too
abstract?  If you were given these guidelines would you be able to make
a decision on whether to define an item as an element or as a type?  Are
there other things that you would add to the guidelines?  /Roger

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.