The situation is simplified if one creates named types rather than adhering to the DTD convention of working with elements. The use of named types permits a one-to-one correspondence to JAVA and other object oriented languages, such as C# and Ada.
That is valuable feedback. Although I do not fully agree, it does make a new point and it is food for further discussion...
Within the article, named types are used in the section "A word about extensions". This demonstrates the advantage of named types for extensibility.
"Simplifying the situation" is not the first thing I'd think of though when talking about named types. Their purpose in XML-Object mapping is new to me, but I can imagine they have their added value there. Personally I prefer using API's like XStream for that purpose, because it just serializes XML regardless of its schema.
XStream is what I used in the developerWorks article "RESTful SOA using XML".
An additional advantage of that approach is that it also allows you to serialize XML formats that are described by a RELAX NG schema instead of an XML Schema. RELAX NG is more DTD style, like most XML Schema examples in the article.
There is another advantage of using named types that is not in the article and not in the comment, but still within the scope of the article because of maintainability. This is the fact that a named type can be reused under multiple different element names. Think for example about a <VisitorAddress>, <PostalAddress> and <BillingAddress> all containing the same <Street>, <Number>, <PostalCode>, <City>, <State> and <Country> elements.
XML Schema can do a lot more than what was shown in the post, and things that are not possible in RELAX NG. An interesting discussion is whether such detailed constraints actually belong in a schema or not. But that is a whole different post! :-)
No comments:
Post a Comment