Hi Kiran

I've CC'd the list in case anyone else has a similar problem.

If a recent version of crimson.jar or xerces.jar is on the CLASSPATH then
dom4j will use that as the SAX parser via JAXP. If none of these are on the
CLASSPATH then a bundled version of Aelfred is used, which does not
validate.

So for DTD validation put crimson.jar or xerces.jar on the CLASSPATH. If you
wish to validate against an XML Schema then try xerces.jar.

An alternative is to use Sun's MSV library for validation, which allows you
to use DTD, XML Schema, Relax NG, Relax or TREX as the schema languages.
There's an example in the daily build at
dom4j/src/samples/validate/JARVDemo.java

If you are validating an existing dom4j document then we recommend you try
MSV as it avoids turning the document into text and then parsing it again -
MSV can work purely off of SAX events generated from the dom4j document.

(I'll also add the above to the FAQ)

James
----- Original Message -----
From: "Kiran Chandra" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 04, 2001 11:02 PM
Subject: Query


> hello James,
>
> Is the default parser coming with dom4j a validating parser?I want to
> validate xml documents against a schema ?how can i use this with dom4j
> programming?
>
> I tried with the sample code coming with dom4j.I am creating the Document
> object fro a String.After that i used the code from the example using
> SaxValidator class.the folowing code fragment i used.
> But i am always getting validation as true even if the the document doesnt
> match the XML.Could you please help me how to do this?
>
> As told earlier I am not using the reader but am creaing the xml from a
> String.
>
> The following is the code fragment from the dom4j samples which i used.
> The file for this is \domm4j-1.1\src\samples\validate\SAXVlidatorDemo
>
> // now lets validate
>             try {
>                 SAXValidator validator = new SAXValidator();
>                 validator.setErrorHandler( errorHandler );
>
>                 //this Document object i created from a string using
>                 //the DocumentHelper class
>                 validator.validate( document );
>
>                 println( "Document: " + url + " is valid!" );
>             }
>             catch (SAXException e) {
>                 println( "Document: " + url + " is not valid" );
>                 println( "Exception: " + e );
>             }
>         }
>
>
> thanks and regards
> Kiran C
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to