[xsd-users] Reading of Schemas at Validation?

Boris Kolpackov boris at codesynthesis.com
Wed Nov 25 11:10:03 EST 2009


Hi Ian,

Durkan, Ian <ian.durkan at progeny.net> writes:

> Which option describes how the schema is stored in memory?  
> 
> 1. Generated functions read in the schema file (and the files it
> includes) only the first time a parsing function is called with a
> particular schema, and then a representation of the schema is held in
> memory until our program is terminated.  
> 
> 2. Schema file(s) are read each time a parsing call is made.

If you are using the generated parsing functions then it is (2). These
functions are stateless so they create a new XML parser, load the schemas,
parse the XML document and then destroy the parser.


> If the second option is true, is there a way to reuse the schema-in-
> memory for every parsing call?

Yes, you can pre-load and reuse the schemas along with the XML parser
to parse multiple XML documents. See the 'caching' example in the
examples/cxx/tree/ directory of the XSD distribution for more information
on how to do this.

It is also possible to pre-compile the schemas into a binary representation
and even embed them into the application. While there is no example that
shows how to do this in XSD 3.2.0, we have created such an example for the 
next release of XSD. Let me know if you are interested and I will send it
to you.

Boris



More information about the xsd-users mailing list