0

Xerces C++ : Test Slow XML Validation against XSDs with unique and key elements

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.

Using Java

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.

Download

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 PParse.exe

Set PATH

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.

Final Word

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.