Re: [xsl] Validate Doc XML with XML Schema

Subject: Re: [xsl] Validate Doc XML with XML Schema
From: "Eder de Oliveira" <eder@xxxxxxxxxxxxx>
Date: Thu, 17 Feb 2005 11:33:06 -0300
Hello!

I am using the exemple:

// create a SchemaFactory that conforms to W3C XML Schema
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);


 // set your error handler to catch errors during schema construction
 sf.setErrorHandler(myErrorHandler);

 // parse the purchase order schema
 Schema schema = sf.newSchema("po.xsd");

 // get a DOM factory
 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();

 // configure the factory
 dbf.setNamespaceAware(true);

 // set schema on the factory
 dbf.setSchema(schema);

 // create a new parser that validates documents against
 // the schema specified (po.xsd)
 DocumentBuilder db = dbf.newDocumentBuilder();

 // attach an error handler to detect document validation errors
 db.setErrorHandler(myErrorHandler);

 // parse and validate against po.xsd an XML document
 Document purchaseOrderDoc = db.parse("po.xml");

I have a problem:
// set schema on the factory
 dbf.setSchema(schema);
My DocumentBuilderFactory haven't "setSchema".

I'm using j2sk 1.4

Can I help me please?

Thanks
Eder


----- Original Message ----- From: "Michael Kay" <mike@xxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, February 17, 2005 9:53 AM
Subject: RE: [xsl] Validate Doc XML with XML Schema



Off-topic for this list, but see the following article on JAXP 1.3:

https://jaxp.dev.java.net/article/jaxp-1_3-article.html

Saxon-SA 8.3 supports the JAXP 1.3 schema validation API, and includes
further examples of its use.

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



-----Original Message-----
From: Eder de Oliveira [mailto:eder@xxxxxxxxxxxxx]
Sent: 17 February 2005 13:23
To: XSL - list
Subject: [xsl] Validate Doc XML with XML Schema

Hi People,

Please, Anyone can help me!

I would like validate a doc XML using XML Schema in JAVA and
parser SAX

Have any samples ?

Thanks a lot
Eder

Current Thread