Skip to Content.
Sympa Menu

xom-interest - RE: [XOM-interest] Validate questions

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: "'Arjan Huijzer'" <huijzer AT gmail.com>, <XOM-interest AT lists.ibiblio.org>
  • Cc:
  • Subject: RE: [XOM-interest] Validate questions
  • Date: Thu, 27 Jan 2005 10:23:49 -0000

Since Saxon can accept a XOM document as a Source, one option is to do
schema validation like this:

System.setProperty("javax.xml.transform.TransformerFactory",

"com.saxonica.SchemaAwareTransformerFactory");
TransformerFactory factory = TransformerFactory.newInstance();
factory.setAttribute(FeatureKeys.SCHEMA_VALIDATION,
new Integer(Validation.STRICT));
factory.setAttribute(FeatureKeys.VALIDATION_WARNINGS,
Boolean.TRUE);

Transformer trans = factory.newTransformer();
Source source = new DocumentWrapper(jdomDocument);
trans.transform(source, new Sink());

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

> -----Original Message-----
> From: xom-interest-bounces AT lists.ibiblio.org
> [mailto:xom-interest-bounces AT lists.ibiblio.org] On Behalf Of
> Arjan Huijzer
> Sent: 27 January 2005 09:52
> To: XOM-interest AT lists.ibiblio.org
> Subject: [XOM-interest] Validate questions
>
> Hi all,
>
> I have been adding a validity check to my XML documents and have a
> couple of questions:
>
> 1. Does XOM support validation against an XML schema? So far, I have
> only been able to validate againt a DTD
>
> 2. Do I have to include a doctype declaration to my XML document or
> can I also declare in my java code against which DTD the document
> should be validated.
>
>
> Furthermore, I noticed some odd behaviour. My code to parse an XML
> document used to be:
>
> Document doc = parser.build("c:/xomtest/books.xml");
>
> This worked fine until I switched to Xerces, which bow trows an
> IOException. I had to modify my code to read:
>
> Document doc = parser.build("file:///c:/xomtest/books.xml");
>
> Is this second way the correct way? I am a bit puzzled.
>
>
> Thanks in advance for any help,
>
> Arjan Huijzer
> _______________________________________________
> XOM-interest mailing list
> XOM-interest AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/xom-interest
>





Archive powered by MHonArc 2.6.24.

Top of Page