[jdom-commits] CVS Update: jdom-contrib/src/java/org/jdom/contrib/schema
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/src/java/org/jdom/contrib/schema
In directory chimbo:/tmp/cvs-serv9604/src/java/org/jdom/contrib/schema
Added Files:
Schema.java ValidationError.java
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: no file Schema.java Status: Needs Checkout
Working revision: 1.1 Wed Apr 30 01:07:35 2003
Repository revision: 1.1 /home/cvs/jdom-contrib/src/java/org/jdom/contrib/schema/Schema.java,v
Existing Tags:
No Tags Exist
===================================================================
File: no file ValidationError.java Status: Needs Checkout
Working revision: 1.1 Wed Apr 30 01:07:35 2003
Repository revision: 1.1 /home/cvs/jdom-contrib/src/java/org/jdom/contrib/schema/ValidationError.java,v
Existing Tags:
No Tags Exist
More information about the jdom-commits
mailing list