[xsd-users] XSD Parser Slow.

Hari Kalva hari at cse.fau.edu
Wed Feb 21 10:02:21 EST 2007


Boris, Thanks. I had an element with 12 sub-elements each with maxOccurs of
255. I changed this to unbounded as per your suggestion and the parsing
delay is gone! I haven't timed it but no noticible delays. Thanks a lot!
-hari

-----Original Message-----
From: Boris Kolpackov [mailto:boris at codesynthesis.com] 
Sent: Wednesday, February 21, 2007 12:54 AM
To: Hari Kalva
Cc: xsd-users at codesynthesis.com
Subject: Re: [xsd-users] XSD Parser Slow.

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





More information about the xsd-users mailing list