Evry Example I have tried to validate a xml file to a dtd are based on that the user want to parse a file. What if i want to parse and xmldocument from that hasnt been written to the hd yet? I have methods for create a DOM-object and a method for writing it to a file. Im trying to use this code from the faq to parse my to-be-xml-file but i cant get it to work could anyone help me or point me to the right direction.
parser.parse("data.xml"); // <--- Here i want to parse a doc, not file
Could you elaborate on this (if "doc" means org.w3c.dom.Document, it is already parsed...)? For example, do you want to do - parse("<?xml version='1.0'?><root><foo/><bar>...</bar></root>"); - parse(java.io.InputStream) - something else?
I want the source to be non-physic-file. I tried do type, parser.parse(MyDocument) where myDocument is the result of The scenario is that i want to validate a xmldoc to a DTD before i write it down in a file. Accrding to my resources the parse-method only accepts, File, URL resource, InpuStream & String data. So here is the deal really basic. 1. Load xml-flie from hd 2. Add more info to it 3. Validate old info + new info with a dtd 4. If sucessfull then write it down to a file on the hd. Im done with all taks accept number 3. Validating the new document against a DTD. Thanks for your time.. [ February 18, 2004: Message edited by: Je Th ]
Joined: Jan 23, 2002
You could combine this and this to produce an in-memory XML file including a DOCTYPE declaration, and then parse it like this. It's a bit ugly, but should work.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com