Using XMLBeans when supplied a dtd

Discussions

XML & Web services: Using XMLBeans when supplied a dtd

  1. Using XMLBeans when supplied a dtd (2 messages)

    Our application is provided data by an external data vendor in an XML format for which we were provided a DTD. We would like to use XMLBeans to pull information out of the XML structure, however it seems XMLBeans requires a Schema and does not funtion against a DTD. Can anyone recommend what strategy we could pursue to still be able use XMLBeans?
  2. Make a schema.
  3. Option 1 is that XML Beans isn't the only "schema compiler" around, so you could try a different tool. Otherwise, as noted, you need a Schema. A number of XML tools, like XML Spy and oXygen, can create a W3C XML Schema from a DTD, as can Trang: http://www.thaiopensource.com/relaxng/trang.html However, a couple of caveats: you need to check that the generated Schema is a correct translation of the DTD. That will depend on the complexity of the DTD. You need someone to check it, and/or you need to check the Schema using XML samples that validate against the Schema. The other caveat is that the style of the generated Schema may not be ideal for XML Beans. DTD to Schema converters tend to create Schemas with lots of global elements, whereas Schema compilers tend to work best with Schemas with mostly local elements. So there may be some value in modifying the Schema after you've generated it, to better suit XML Beans or whichever Schema compiler you are using. Cheers, Tony. ---- Author, "XML APIs" chapter, "Advanced XML Applications from the Experts at The XML Guild" http://www.amazon.com/XML-Power-Comprehensive-Guide-Guides/dp/1598632140/