Java - using XML with XSD?

Hey guys, I’ve recently started learning about XML and all the other hordes of file types associated with it. However, I’m having trouble finding info about how to actually use validated XML files within my game.

For example, I know how to extract element names using both SAX and DOM, but all this leaves me with is a bunch of Strings and if statements. Instead, is it possible for the document to actually read the XSD file and extract the file types of the attributes? So that everything isn’t CDATA?

Thanks

To use XSD driven typed data models, you need something like JAXB (https://jaxb.dev.java.net/tutorial/), but this is maybe overkill for games. Alternatives are XStream (http://xstream.codehaus.org/) or even not xml at all: http://code.google.com/p/yamlbeans/

If you already have the XSD, then http://xmlbeans.apache.org/ will generate a set of objects to parse and create new XML documents

Thanks for the tips, guys. I’ll research the links and post back in a bit.