[xsd-users] Performance issues with XSD

Boris Kolpackov boris at codesynthesis.com
Thu Jun 29 05:08:34 EDT 2006


Hi Gérald,

Gérald GIRAUD <gerald.giraud at artal.fr> writes:

> We have made some performance tests with XSD and got some surprising results.
> Our test program performs the following actions:
> We measure the cpu time consumed to read a xml file into a C++ object and
> serialize it into another external file (and this 10000 or 100000 times)
>
> In our sample, we only change the "book maxOccurs" from the .xsd file.
>       <xsd:element name="book" type="lib:book" maxOccurs="5"/>
>
> When the maxOccurs=5, the measured time is 5 seconds.
> When the maxOccurs=500, the mesaured time is 141 seconds, and this with
> the same data (library_3.xml that contains only 3 books declared) !
> Is there a way to fix this problem. Maybe our code is not correct : is it
> possible to ensure the performance of XSD in that sample (even for
> maxOccurs=5) ?

I think Raul is right; this is a Xerces-C++ schema processor limitation.
I ran your test for the following cases:

maxOccurs=5          - 2  sec
maxOccurs=500        - 79 sec
maxOccurs=unbounded  - 2  sec

You may also want to disable Xerces-C++ validation altogether by passing
the dont_validate flag:

std::auto_ptr<class catalog> l (catalog (argv[1],
                                xml_schema::flags::dont_validate));

This makes sense if you are sure the XML instances are valid, for
example, because they were produced by the same application. With
validation disabled, I get 1 sec on your test.

If you need XML Schema validation and is parsing multiple files,
there is a number of ways to optimize this process as described
in the following article:

"Cache and serialize XML Schemas with Xerces-C++"

http://www-128.ibm.com/developerworks/webservices/library/x-xsdxerc.html


> I join the sources of our sample (driver.cxx, library.xsd and library.xml)

Thanks, that was very helpful.

hth,
-boris
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 652 bytes
Desc: Digital signature
Url : http://codesynthesis.com/pipermail/xsd-users/attachments/20060629/fb018b1a/attachment.pgp


More information about the xsd-users mailing list