Skip to main content

JAXP xml validation taking around 800 ms to validate a small xml file.

No replies
sanjivacharyya
Offline
Joined: 2010-05-11
Points: 0

Hi,

I am trying to validate an xml file against an xsd schema definition using JAXP.
It is observed that it is taking around 700-800 ms while validating a small xml file.
Code snapshot is given below:
------------------------------------------------------------------------------------------------------------------------------
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
DocumentBuilderFactory factory = DocumentBuilderFactory
.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
factory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaSource",
SchemaUrl);
DocumentBuilder builder = factory.newDocumentBuilder();
Validator handler = new Validator();
builder.setErrorHandler(handler);
builder.parse(XmlDocumentUrl);
------------------------------------------------------------------------------------------------------------------------
xml file is:
-------------------------------------------------------------------------------------------------------------------------

Declarative Programming in Java
Narayanan Jayaratchagan

Data Binding with XMLBeans
Daniel Steinberg

----------------------------------------------------------------------------------------------------------------------------
xsd file is:
----------------------------------------------------------------------------------------------------------------------------

-----------------------------------------------------------------------------------------------------------------------------
Please help me out in tuning its performance.