Chad La Joie <[EMAIL PROTECTED]> wrote on 02/10/2007 11:08:20 PM:

> I'm attempting to set up a JAXP 1.3 DocumentBuilderFactory that will 
> produce a DocumentBuilder that validates against a given Schema during 
> parsing.  If I create a Schema object and set it on the Factory, create 
> a Builder from the Factory, and then parse a document I get the 
> following exception:
> 
> Document is invalid: no grammar found

That error message comes from the DTD validator. If you set a Schema on 
the factory and set validating to true, you get both schema validation and 
DTD validation. I assume you only want schema validation, so you shouldn't 
be calling setValidating().

> Additional settings on the Factory include setting ignoreComments, 
> ingoreElementContentWhitespace, namespaceAware, and validating to true. 
>     Also, "http://java.sun.com/xml/jaxp/properties/schemaSource"; and 
> "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; are *not* set 
> as attributes.
> 
> However, if I do *not* set it on the Factory, create a parser, parser 
> the document, and *then* manually use that same Schema object to 
> validate the resultant Document, it validates correctly.
> 
> I searched the archives but all the references to this error I could 
> find involved setting the 
> "http://apache.org/xml/features/validation/schema"; feature.  However, 
> I'm trying to avoid implementation specific settings.
> 
> Can anyone offer some information on this problem?  Certainly the JAXP 
> documentation [1] make it seem like all I have to do to turn on schema 
> parsing is set the Schema object on the Factory.
> 
> Thanks in advance.
> 
> [1] 
> http://java.sun.com/j2se/1.5.
> 0/docs/api/javax/xml/parsers/DocumentBuilderFactory.
> html#setSchema(javax.xml.validation.Schema)
> 
> -- 
> Chad La Joie             2052-C Harris Bldg
> OIS-Middleware           202.687.0124
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to