Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XML Schema to Java options

 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am about to start out on a large-ish Java application processing XML files whose content is defined by a complicated XML Schema.
I would like to be able to generate Java classes to represent the elements described in the Schema. To write these entirely by hand would be a very onerous task, so I hope that an automated tool will be able to do some of the process.
I have investigated JAXB, Castor and BreezeFactor tools for generating Java from an XML Schema. None of these could cope with our schema. One problem was that none of them supported simpleType definitions whose content was a list.
  • Are there any other such tools that I should be considering?
  • How fast are the existing tools evolving?
  • Is it likely that they will support my requirements in the near future?
  • Is there another approach that I could take to the problem?


  • All suggestions gratefully received.
    P.S. Here's an example of what JAXB and Castor didn't like...

    [ November 25, 2002: Message edited by: Peter Chase ]
     
    Anonymous
    Ranch Hand
    Posts: 18944
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi Peter,
    I can see one solution here: apply a simple XML transformation to conform to what is supported by Castor or JAXB to read the input XML into Java objects. To serialize, just do the reverse (another XSLT).
    I'm sure you'll find lots of experts in this forum to help you on the best way to do this.
    Cheers
     
    Peter Chase
    Ranch Hand
    Posts: 1970
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    I can see one solution here: apply a simple XML transformation to conform to what is supported by Castor or JAXB to read the input XML into Java objects. To serialize, just do the reverse (another XSLT).

    Do you mean transform the schema itself or the XML data (conforming to the schema), or both?

    I'm sure you'll find lots of experts in this forum to help you on the best way to do this.

    I do hope so!
     
    Balaji Loganathan
    author and deputy
    Bartender
    Posts: 3150
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Peter Chase:

    I do hope so!

    When its comes to validation against a Schema!.. my suggestion could be to write an XSL as a validator against XML. I just attempted it but haven't completed it fully due to other works. With XSL you have an advantage of throwing out user understandble error, than the one that comes out of xerces or sun MSV.
    Rgds
    Balaji
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic