[jdom-commits] CVS Update: jdom-contrib

nobody nobody at chimbo.servlets.com
Tue Apr 29 18:07:35 PDT 2003


****************************************
Date:   Tue Apr 29, 2003 @19:07:35 MDT
Author: 

Update of /home/cvs/jdom-contrib
In directory chimbo:/tmp/cvs-serv9604

Modified Files:
build.xml
Log Message:
Contrib schema package from Laurent:

Attached is a proposal for supporting in-memory validation of JDOM documents
against schemas.
This code relies on JARV (Java API for RELAX Verifiers,
http://iso-relax.sourceforge.net/JARV/) and Sun's Multi-Schema Validator
implementation.

To validate a document against a W3C XML Schema definition:

import org.jdom.contrib.schema.Schema;

String uri = <The URL of the schema document>;
Document doc = <a JDOM document>;

Schema schema = Schema.parse(uri, Schema.W3C_XML_SCHEMA);
List errors = schema.validate(doc);
if (errors != null) {
// Validation errors
for (Iterator i=errors.iterator(); i.hasNext(); ) {
ValidationError e = (ValidationError)(i.next());

System.out.println(e);
}
}
// Else: No error, document is valid.

The current limitations are those of JARV, i.e. no support for validating a
document against multiple schemas. This can be work around for elements
(calling validate(Element) on another Schema) but not for attributes.

Regards,

Laurent


===================================================================
File: build.xml        	Status: Up-to-date

   Working revision:	1.18	Wed Apr 30 01:07:13 2003
   Repository revision:	1.18	/home/cvs/jdom-contrib/build.xml,v

   Existing Tags:
	jdom_1_0_b9              	(revision: 1.17)




More information about the jdom-commits mailing list