[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: XML Schemas: Best Practices
I find your interpretations useful, and by publishing them here we get a chance to disagree, which I am about to do: I established a circumstance when I want to re-use a type and cannot re-use an element (both MovingFromAddress and MovingToAddress being of type Address). I then said that in other cases, the type will always be used to create an element with the same name (such as SSN). In the latter case, we could re-use an element (but how do we *know* how it will be used - I am guessing that an SSNtype will always be used to create an element "SSN"). However, I *prefer* (and this is a style matter) to re-use the data type so that we have consistency and my guidelines are easier to use for novice schema writers. Once they are reasonably familiar with the common definition set, they will know, without having to refer back to the set that they should use SSNtype. This is hardly more verbose than re-using the element and gives consistency. However, as I said, it is a style issue. I would be very happy to hear from anyone who can demonstrate that one approach provides better performance in the parser than the other. Paul Spencer Author: XML Design and Implementation (Wrox Press) Co-author: Beginning XML (Wrox Press) Boynings Consulting - Delivering XML to industry and government http://www.boynings.co.uk/ -----Original Message----- From: Roger L. Costello [mailto:costello@m...] Sent: 12 October 2000 18:51 To: xml-dev@l... Cc: costello@m...; Cokus,Michael S.; Pulvermacher,Mary K.; Heller,Mark J.; JohnSc@c...; Ripley,Michael W. Subject: Re: XML Schemas: Best Practices 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|