Ware xml validating parser
For years they've caused trouble because the people that write them do them by hand, so errors naturally occurred.It's high time we get around to validating them and providing feedback on what's wrong when trying to use these XML files.W3C_XML_SCHEMA_NS_URI); // load a WXS schema, represented by a Schema instance Source schema File = new Stream Source(new File("my Schema.xsd")); Schema schema = Schema(schema File); // create a Validator instance, which can be used to validate an instance document Validator validator = Validator(); // validate the DOM tree try catch (SAXException e) 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.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).Is there anything I can easily add to the front of the source to prevent this? in these dais I had the same problem; I found this thread looking for a solution. Is there a way to tell the parser to ignore these DTD related errors?
You can then use these objects to build an XML document based on this schema.
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.
But then again, validating XML against XSD files is a rather heavy weight problem.
As for a tool to do this for you, XMLFox seems to be a decent freeware solution, but not having used it personally I can't say for sure.