You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by da...@exxonmobil.com on 2003/09/03 20:59:02 UTC

API for pre-loading schema

Hi all,

I'm looking to pre-load a schema into the parser and validate an XML file
against that schema, regardless of the file's NoNamespaceSchemaLocation.
It looks like this might be possible from the docs I've looked at...but
does anyone have a quick example I could use to get started?  I know I
could parse the file, change the NoNamespaceSchemaLocation, and parse it
again, but that seems clumsy.  I am currently using a DOMParser but would
be open to other approaches.

Thanks very much,

David Shontz
ExxonMobil Exploration UTC
Application Support/Application and Data Integration
CORP-RR-603
281-654-7214
Email: David Shontz/U-Houston/ExxonMobil
Internet Email: david.shontz@exxonmobil.com


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: API for pre-loading schema

Posted by Ron Rothblum <RO...@il.ibm.com>.
Look at the grammer explanations at xerces website. What you do is preparse
the schema and save it as a grammer, then when loading the xml you specify
thaat it shuld use that grammer and not the schema specified. Here is what
you do:

XMLGrammarPreparser preparser = new XMLGrammarPreparser();
preparser.registerPreparser(XMLGrammarDescription.XML_SCHEMA, null);
preparser.setProperty(GRAMMAR_POOL, grammarPool);
preparser.setFeature(NAMESPACES_FEATURE_ID, true);
preparser.setFeature(VALIDATION_FEATURE_ID, true);
preparser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, true);
preparser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, true);
preparser.setFeature(SCHEMA_ELEMENT_DEFAULT_ID, true);
preparser.setFeature(SCHEMA_NORMALIZED_VALUE_ID, true);

XMLInputSource inputSource = new XMLInputSource(null,null,null,schema,null
);
preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, inputSource);

and then when parsing add the property:

parser.setProperty(GRAMMAR_POOL, grammarPool);


Ron Rothblum
Active Technologies Department
IBM Haifa Research Labs
Phone:   +972 4 829-6459


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org