Hi David,
David Aldridge <[EMAIL PROTECTED]> writes:
> That's all fine and dandy, but is there any way to cache SomeThing.xsd
> Without re-using the same DOMBuilder?
The process is a bit convoluted and I haven't used it myself but I
think it will work:
1. Create a GrammarResolver object (defined in
validators/common/GrammarResolver.hpp) with 0 for the grammarPool
argument:
GrammarResolver* gresolver = new GrammarResolver (0);
This will trigger the resolver object to create an XMLGrammarPool
object which can be accessed via getGrammarPool(). There does not
seem to be a way to create XMLGrammarPool implementation directly.
2. Create DOMBuilder and pass the grammar pool retrieved with
getGrammarPool() as the third argument to createDOMBuilder():
XMLGrammarPool* gpool = gresolver->getGrammarPool();
DOMBuilder* gparser = impl->createDOMBuilder(
DOMImplementationLS::MODE_SYNCHRONOUS,
0,
XMLPlatformUtils::fgMemoryManager,
gpool);
Set various features as you did in your ParseFooAndBar function.
3. Call the loadGrammar() functions for your schemas:
gparser->loadGrammar ("foo.xsd");
gparser->loadGrammar ("bar.xsd");
This will result in scheme grammars for foo.xsd and bar.xsd being
loaded into gpool. After this you can release gparser.
4. Now you can create as many parsers as you want with gpool, as shown
in step 2. Instead of calling loadGrammar(), you will call parseURI().
5. When you are done with gpool, delete gresolver.
Boris
--
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding