XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
XML Schema: "Best used with the ______ tool"


Hi Folks,


ANALOGY - BROWSER WARS

Until recently there was much disparity in browser support for the standards (HTML, CSS). As a consequence you oftentimes saw on Web pages: 

    "This Web page is best viewed in the _______ browser."

Alternatively, Web page designers would use only the portions of the standards that all the browsers supported.


XML SCHEMA - SIMILAR SITUATION?

Are we in a similar situation today with XML Schema tools? When you create an XML Schema will you inform your clients:

    "This XML Schema is best used with the ____ tool." 

A colleague did some digging into various XML Schema tools and found disparity in their support for the XML Schema constructs:

   - Some tools support repeatable sequences, others don't

        <sequence maxOccurs="unbounded">
           ...
        </sequence>

   - Some tools support choice, others don't 

        <choice>
           ...
        </choice>

   - Some tools support abstract elements, others don't

        <element name="Publication" abstract="true" type="PublicationType" />


Below is the message from my colleague. Can you confirm or deny his findings?

----------------------------------------------------------------

The tools that I've been looking at are: 

   - AXIS 1.4 (within Eclipse), 
   - AXIS 2, 
   - JAXB, 
   - Netbeans (which uses JAXB), and 
   - Visual Studio.  

I wanted to see if these tools supported XSD constructs, or had common problems with XSD.  I have found that the tools above have some issues with Substitution Groups, Repeating Sequences and Choices.  The issues I ran into are described below.  Please let me know if you've used these tool and have found ways to get around these problems.  Also let me know if there are other instances where generated code is lacking.


Substitution Groups:


The schema I created had a "Publications" element that consisted of a list of "Publication" elements.  The "Publication" element was abstract and could be substituted with "Book" and "Magazine" elements.

- For some reason, my Axis 1.4 implementation had the "Book" element substitute for the "Publications" element (instead of the "Publication" element).  This resulted in a series of "Publications".  The Axis 1.4 implementation keeps the original element name and uses the xsi:type attribute to indicate the type the base element was substituted for.  For example:  

     <Publications xsi:type="BookType"/>

- Like Axis 1.4, Axis 2 and Visual Studio both keep the original element name and use the xsi:type attribute to indicate the type the base element was substituted for.  For example: 

     <Publication xsi:type="BookType"/>.  

This is wrong because the Publication element is abstract and should not appear in an instance.

- JAXB creates a valid instance.  However, it gets a SOAP fault exception related to the extended elements.  For instance, in the error below, the Book element extended Publication with an ISBN element.  I'm not sure what to think about this.

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: org.xml.sax.SAXException: Invalid element in org.mitre.www.bookstore.PublicationType - ISBN 


Repeating Sequences:


- Axis 1.4 only allows for a single occurrence of a sequence.

- JAXB can handle repeating sequences.  However, it leaves the developer with the task of "manually" formatting the XML document.  Repeating sequences are treated as a list of generic JAXBElements. The developer is required to place these elements in the order prescribed by the XML Schema.

- Visual Studio treats each element in a repeating sequence as an unbounded element.  Therefore, a repeating sequence of A's and B's, turns into A, A, A, B, B, B ...instead of A, B, A, B, A, B.

- Axis 2 had no problem with the repeating sequence.  It creates a class wrapping the elements within the sequence.


Choice:


- Axis 1.4, and JAXB treat the elements within a choice as if they were in a sequence.  This allows for generating an instance with multiple elements ... for instance an instance with elements A and B, instead of element A or B.  

- Axis 2 also treats elements within a choice as if there were in a sequence.  However, the generated instance only includes the choice that was set last.  For instance, if I set A, then set B ... the B element would appear in the instance.  This alleviates the problem above.  However, when I had a choice in a complexType derived by extension (in my example, MagazineType extend PublicationType with a choice of Issue or Volume number), all of the base elements were lost (the elements in Publication type ... author, etc).  

- Visual Studio had no problems with choice.




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS