Validating xml parser purpose
Alternatively if you use Stax for writing content (or a library that uses or can use stax), Woodstox can also directly support validation when using XMLStream Writer.
Here's a blog entry showing how that is done: If you are generating XML files programatically, you may want to look at the XMLBeans library.
The definition of the dtd and xsd has to be in the xml! One more answer: since you said you need to validate files you are generating (writing), you might want to validate content while you are writing, instead of first writing, then reading back for validation.
You can probably do that with JDK API for Xml validation, if you use SAX-based writer: if so, just link in validator by calling 'Validator.validate(source, result)', where source comes from your writer, and result is where output needs to go.
Be fore warned though, it is a heavy weight solution.
But then again, validating XML against XSD files is a rather heavy weight problem.
For example:" is probably a network location, so it'll by default go out and hit the network with each and every validation, not always optimal.
, my xml file has validated" except XMLSyntax Error: #handle exception here print "Oh NO!W3C_XML_SCHEMA_NS_URI); Schema schema = Schema(Thread.current Thread()Context Class Loader()Resource("your.xsd")); Validator validator = Validator(); validator.validate(xml File); I had to validate an XML against XSD just one time, so I tried XMLFox. The help instructions didn't seem to match the interface.I ended up using Liquid XML Studio 2008 (v6) which was much easier to use and more immediately familiar (the UI is very similar to Visual Basic 2008 Express, which I use frequently).The drawback: the validation capability is not in the free version, so I had to use the 30 day trial.The XML DOM (Document Object Model) defines the properties and methods for accessing and editing XML.