[xsd-users] XSD Parser Slow.

Boris Kolpackov boris at codesynthesis.com
Wed Feb 21 00:53:32 EST 2007


Hi Hari,

Hari Kalva <hari at cse.fau.edu> writes:

> Hello, I am using the C++/Tree mapping to parse an XML document. The parser
> takes almost 8 seconds to parse a simple XML document with 3 elements. The
> schema has about 28 elements. The XSD generated code is 280 K for the cxx
> file and 130 K for the hxx file. The parser used to take about 3 seconds
> when I had about 20 elements. Even 2 seconds for a simple document is very
> slow.

Hm, that's strange. We have a benchmark with about 6000 sub-elements
which performs non-optimized in about 10ms without validation and
12ms with validation. There has got to be something special about your
schema and/or instance. Would it be possible for you to send it in
so I can figure out what's going on?


> I am using XSD 2.3.

There were some optimizations in 2.3.1 so you may want to give it a try.


> Does the structure of the schema affect this?

There are several things you may want to check:

1. Make sure your XML instance does not reference the schema over
   HTTP. If that's the case and validation is enabled then the
   parsers has to fetch your schema every time you parse your
   instance.

2. Check if your schema has any large maxOccurs values. If so
   then you may want to replace them with "unbounded" or disable
   validation. Xerces-C++ performs significantly slower with
   large maxOccurs.

3. Disable validation by passing the xml_schema::flags::dont_validate
   flag to the parsing function. This way you can figure out what takes
   so much time: parsing or validation.


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/20070221/de298bbb/attachment.pgp


More information about the xsd-users mailing list