And the output (which shows nothing but NULL values:
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 10 errors. Please call the setErrorHandler method to fix this.
Error: URI = "null", Line = "2", : Document root element "character", must match DOCTYPE root "null".
Error: URI = "null", Line = "2", : Document is invalid: no grammar found.
[#text:
]
[name: null]
[#text:
]
[type: null]
[#text:
]
[model: null]
[#text:
]
[physics_model: null]
[#text:
]
[physics_size: null]
[#text:
]
[shadows: null]
[#text:
]
As always, any hints or suggestions are completely welcome.
Anyway, there's a link to the complete sources where you can take a look at these packages:
gcore.config - runtime representation of the GameObjects, GameStates and Components
gcore.config.xml - xml parsers to convert from XML to the above runtime rep.
I designed this runtime configuration, so I can later use it inside a (todo) level editor, or even autosave or something. Being easier to just parse/export xml…
If you just plan to use XML as a format which you'll map to objects, and you are not going to use all the functionality (xpath, xsl or whatever), you can avoid a lot of extra work. Maybe you might want to have a look at:
Apache Jakarta Commons Configuration (http://commons.apache.org/configuration/). Reads properties and lists of properties from .properties, xml or a variety of sources.
Apache Jakarta Commons Digester (http://commons.apache.org/digester/). Rule based engine to digest XML and build in-memory object structures. Powerful but a bit difficult to master I guess.
I have personally used Commons Configuration and Commons Digester, and I they are really helpful in order to construct structures in memory or to read data from xml.
They are good pieces of software indeed, but I always tend to avoid the dependency in yet another framework. The XML parsing code I use (including the one here) took me about half an hour to design and type, so it wasn't really a waste of time.