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 "Wax, Ed" <Ed...@csgsystems.com> on 2004/03/04 18:21:01 UTC

XMLGrammarBuilder sample

I'm having trouble with one of the sample programs that comes with he xerces-j 2.6.2 distribution.  It is:
~xerces/samples/xni/XMLGrammarBuilder.java

As distributed, it will preparse multiple XSD files (grammars).  I have an XSD file with an intentional bug.  If I specify that XSD file as the first one to preparse, the error will be reported.  However, if I specify a valid XSD file first and then the one with the bug, the error will not be reported.  Is there a method to "reset" things?

Here's the block of code that preparses the specified grammars (XSD files):

	...
	// parse the grammar...
	try {
		if (isDTD) {
			for (i = 0; i < externalDTDs.size(); i++) {
				Grammar g = preparser.preparseGrammar(
					XMLGrammarDescription.XML_DTD, 
					stringToXIS((String)externalDTDs.elementAt(i)));
				// we don't really care about g; grammarPool will take care of everything.
			}
		} else { // must be schemas!
			for (i = 0; i < schemas.size(); i++) {
				Grammar g = preparser.preparseGrammar(
					XMLGrammarDescription.XML_SCHEMA, 
					stringToXIS((String)schemas.elementAt(i)));
				// we don't really care about g; grammarPool will take care of everything.
			}
		}
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(1);
	}
	...

Regards,
Ed