Hi Bram,

Bram Vandeputte <bram.vandepu...@cs.kuleuven.be> wrote on 04/24/2009
05:33:36 AM:

> Hi All,
>
> I am trying to build a customized online validator, and I need the "
> http://apache.org/xml/properties/external-SchemaLocation"; property
> for explicitly defining a schema to validate against, even if no
> schema is provided in the document.
>
> The problem is that I always get a : SAXNotRecognizedException :
"Property '
> http://apache.org/xml/properties/external-SchemaLocation' is not
recognized.".
>
> I am using Xerces-j 2.9.1 . I have tried it by setting this property
> to the xmlreader and the saxparser itself, but nothing works...
> Could you please tell me what I am doing wrong ?

The name of the property is
"http://apache.org/xml/properties/schema/external-schemaLocation";. You
capitalized the 's' on schemaLocation. That's why it wasn't recognized.

> Here is my code :
>
> System.setProperty("javax.xml.validation.SchemaFactory:http://www.
>
w3.org/2001/XMLSchema","org.apache.xerces.jaxp.validation.XMLSchemaFactory");
> System.setProperty("org.apache.xerces.xni.parser.XMLParserConfiguration",
> "org.apache.xerces.parsers.IntegratedParserConfiguration");
> String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
>
> SAXParserFactory spf = SAXParserFactory.newInstance();
> spf.setValidating(true);
> spf.setNamespaceAware(true);
> spf.setFeature("http://apache.org/xml/features/validation/schema";, true);
>
> parser = spf.newSAXParser();
>
> XMLReader xmlReader = parser.getXMLReader();
> xmlReader.setProperty("http://apache.org/xml/properties/external-
> SchemaLocation","http://ltsc.ieee.org/xsd/LOM http://ltsc.ieee.
> org/xsd/lomv1.0/lomLoose.xsd");
>
> Thanks a lot in advance for you help !

If you're just starting to write your application I'd suggest using the
JAXP Valdation API [1] instead of the Xerces specific features and
properties. You'll get better performance (from the grammar caching) and
more portable code. Should also avoid setting the
"org.apache.xerces.xni.parser.XMLParserConfiguration" system property to
something other than the current default (or one that extends the default)
unless you have a specific reason to do so.
"org.apache.xerces.parsers.IntegratedParserConfiguration" is ancient and
doesn't support many of the features introduced in recent releases.

> greetings,
> Bram Vandeputte
>
>
> --
> Bram Vandeputte
>
> Katholieke Universiteit Leuven
> Dept. Computer Science
> Celestijnenlaan 200A, A03.010
> B-3001 Leuven, Belgium
>
> Phone: +32 16 327659
> Mob:   +32 474 667796
> Fax:   -

Thanks.

[1] http://xerces.apache.org/xerces2-j/faq-pcfp.html#faq-4

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrgla...@ca.ibm.com
E-mail: mrgla...@apache.org

Reply via email to