Skip to main content

XSD-Validation speed not linear

3 replies [Last post]
patriclicht
Offline
Joined: 2007-09-28
Points: 0

Hi all

I'm validating an xml file using an xsd schema with JAXP. My xml contains a huge amount of "position"-nodes. Validating works well for small xml files.

Lets say we have 500 positions, this needs about 1 minute. But when I validate an xml file that contains 1000 positions, the validation needs about 8 minutes....8 times longer for only the double amount of positions.

I'm using JAXP_14_Nightly.jar from September 27, 2007 at 11:15:39 PM. With JAXP SP2 it's even slower.

I also tried to remove keyrefs from my schema, but this didn't help...

Validation code (extract):
***********
String xsdFile = "files://.....";

//Load XSD Schema
SchemaFactory jaxp = SchemaFactory.newInstance(SCHEMALANG);
myXSD= jaxp.newSchema(new StreamSource(xsdFile));

SAXSource source = new SAXSource(new InputSource(_xmlInputStream));

//Validate xml file against XSD file
Validator validator = myXSD.newValidator();

//Register error handler
validator.setErrorHandler(saxErrorHandler);

//Register SAX data handler
SAXResult sax = new SAXResult(saxErrorHandler);
try {
validator.validate(source, sax);
[...]
***********

Any idea?

Thands
Patric

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Patric,

This is an interesting case. Our Japex performance testing doesn't currently monitoring validation. This is a good opportunity to set it up I think. Could you open a new issue with a category "enhancement" in the Jaxp IssueTracker?

Please submit the testcase with xml and xsd files without exposing any sensitive business information.

Thanks!

patriclicht
Offline
Joined: 2007-09-28
Points: 0

Hi

While stripping down my project I found a fatal bottleneck in my SAX ContentHandler. I removed the bottleneck and now the validation time is more or less linear to the XML file size and my speed problem is solved.
Sorry for the confusion. The problem had absolutely nothing to do with the JAXP library.

Patric

joehw
Offline
Joined: 2004-12-15
Points: 0

Hi Patric,

Thanks for informing us the result, and glad that you've solved the problem.

Joe