Subject: Re: Schema validating... during WRITING 2007-10-30 - By Laurent Bihanic
Back Hi,
Jorge Pacheco a ?crit : > Need to tell before going on that I'm not an jdom expert. > > I know how to validate an existing XML against a schema while reading, > parsing; I use SAXBuilder and tell it to do it. > > Now I need to do the other direction; I create on the fly an XML and I > want to validate the creation as well as the parsing. > How can I do it? Should I just create it and right afterwards read it > and validate it with SAXBuilder too? > Should I use SAXOutputter?
Yes, you could that but the jdom-contrib projet already includes a wrapper for SAXOutputter that performs schema validation using Sun's multi-schema validator: org.jdom.contrib.schema.Schema.
The javadoc explains it all but validating a document sums up to: Schema schema = Schema.parse(uri, Schema.W3C_XML_SCHEMA); List errors = schema.validate(doc);
Regards,
Laurent
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|