Title: translation and verification best practices
If you want to validate while you parse the XML, then you've 2 main choices...
 
* try using a validating parser such as Xerces using either DTD or XML Schema validation, use SAXReader(true) to enable validation. You will probably have to create an EntityResolver to be able to resolve the DTD or Schema documents.
 
* use JARV as a SAX filter so you can validate across any schema language (my favourite, RelaxNG as well as DTD, XML Schema, Relax or Trex). Using JARV as a SAX filter allows you to parse the document once into SAX events and create a dom4j Document and perform the validation.
 
 
There are sample programs demonstrating both of these approaches in
 
    dom4j/src/samples/validate
 
        XercesDemo.java - shows how to validate using Xerces
        JARVDemo2.java - shows how to use JARV as a SAX filter
----- Original Message -----
From: Alan Herod
Sent: Friday, January 10, 2003 3:19 PM
Subject: [dom4j-user] translation and verification best practices

I will be receiving XML messages from a third party (e.g. an InputStream). In my application, I do all my work on a DOM4J Document object. I would like have the option for an implementor to perform XSLT and / or XML Schema validation on the incoming XML. Are there some best practices for doing this?

For example, initially I was thinking that I would first make a DOM4J Document object (org.dom4j.tree.DefaultDocument), translate the XML (as shown in the FAQ), and then validate with the MultiSchema Validation package (MSV / JARV). However, the JARV Verifier.verify() method requires an org.w3c.dom.Node instead of a preferred org.dom4j.Node. The JARVDemo examples in the samples folder seem to do the validation during either reading or writing the Document. Will I need to generate the Document object twice? (Once for validation - once for my use)

Thanks,
Al Herod

Reply via email to