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 Dean Des Rosiers <de...@desropolis.com> on 2002/09/10 22:49:06 UTC

XML Schema Preparser Question...

The Xerces’ Grammar Preparser and XSModel classes work very well for me, but
I have come upon a bit of a snag having to do with the GrammarPool.  It is
my understanding that a type definition once placed in a given preparser’s
grammar pool, will be used by that preparser to resolve any references to
that type (i.e.: includes will not be loaded).

I believe this happens in practice.  As of today, my code opens an xml
schema definition using getResourceAsStream() and wraps the stream like so:
new XMLInputSource(null, null, null, <stream>, null).  Xerces threw an error
originally since it couldn’t find any of the includes (which supply my data
types - the includes are located in the jar file in the same
directory/package as the main xsd file).

At this point, I decided to preparse all the include files before parsing
the main xsd, thus placing all the data type definitions in the preparser’s
grammar pool.  When I tried this, Xerces threw no exceptions, and I was able
to acquire an XSModel from the grammar.  The problem is the XSModel doesn’t
work.  model.getComponents(XSConstants.ELEMENT_DECLARATION); returns null.

When I place all the xsds in “user.dir” they are loaded and resolve
properly.  This isn’t a viable solution, however.  Our goal is to read and
write schemas to and from a database.  I have tried to test this
architecture by limiting myself to streams, which I feel would be a logical
“bridge” from a database column to a preparser.  There may be other ways to
skin this cat, but to my knowledge this should work.

What could be causing the Grammar Preparser to fail quietly?  Is there a
debug flag I can set in order to get more information?  Would I be able to
write a plug-in “loader” to resolve the includes myself?

Thanks in advance,
Dean Des Rosiers

P.S.  I’d also like to use schema annotations.  I understand they haven’t
been implemented yet in Xerces.  Is this planned for any specific release?