Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Validating a Document against a schema

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Michael Kay" <mike AT saxonica.com>
  • To: <elharo AT metalab.unc.edu>, "'Lowell Kirsh'" <lowellk AT gmail.com>
  • Cc: XOM-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] Validating a Document against a schema
  • Date: Wed, 21 May 2008 14:34:21 +0100

> You could stream the document through the validator, but if
> you're creating it with XOM and then validating it, I can't
> think of a better way. Off the top of my head I'm not aware
> of any schema validators that work directly on the XOM model.

Saxon will do so. Using the s9api interface:

Processor p = new Processor(true);
XdmNode doc = p.newDocumentBuilder().wrap(xomDocument);
SchemaManager sm = p.getSchemaManager();
sm.load(...the schema...);
sm.newSchemaValidator().validate(doc.asSource());

or you can rely on xsi:schemaLocation to identify the schema if you prefer.

Michael Kay
http://www.saxonica.com/





Archive powered by MHonArc 2.6.24.

Top of Page