Tip: Debugging JAXP Internals

In my latest battle with JAXP and Schema validation, I found out a little trick. It turns out, that implementation classes in JAXP use a debug flag to control stdout debugging. And this little flag is initialized from the system property jaxp.debug
So, starting your program, application server, … with -Djaxp.debug=true enables all sorts of initialization/bootstrap [...]

June 25, 2009  Tags: ,   Posted in: Programming  No Comments

JAXP Schema Validation in Java5 and Java6

I have had a little battle with schema validation of XML documents and thought I would share it with the world.
I wrote the below code on Java5, thinking this was a way of validating a piece of XML against a schema definition. And indeed, it does work on Java5:

SchemaFactory sf = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setSchema(sf.newSchema(schemaUrl));
DocumentBuilder [...]

June 25, 2009  Tags: , , ,   Posted in: Programming  One Comment