This post demonstrates that even Xerces C++ is as slow as Java when validating an XML file with 300,000 elements against an XSD with <xs:unique> or <xs:key> constraint on those elements.
In the previous post – Very Slow XML Validation against XSDs with <xs:unique> and <xs:key> elements, we used Java.
Using Xerces C++
We are using binaries for Windows.
Xerces C++ can be downloaded from this link – http://xerces.apache.org/xerces-c/download.cgi
Don’t write C++ codes
Instead of writing codes, we could use the pre-built applications that go along with the binary release.
Using our Test XML and XSD files
Testing with <xs:unique> constraint
We can see that the application has not yet completed the validation after ~5 to 6 minutes. This is very slow already.
Testing without <xs:unique> constraint
This time it took less than 6 seconds.
But was the XML really validated against the XSD?
Yes! We used an invalid element “nameXX” and the XML validation failed.
Using <xs:unique> or <xs:key> elements for validation is fine. However, if we are processing huge number of elements, using these constraints has a negative impact on an application’s performance.