Hi again,
I have successfully solved the problem by first calling the Unmarshaller without validation, and calling the Validator later with the obtained instance (on-demand validation). The total execution time of the two invocations is insignificant, but the invocation to the unmarshaller with validaton enabled was very big.
If it can help to someone, here is the code:
JAXBContext jc = JAXBContext.newInstance("jfactory.project.xml.modelo"+MODELO);
// Unmarshall without validation
Unmarshaller u = jc.createUnmarshaller();
u.setValidating(false);
u.setEventHandler(new EventHandler(log));
remesa = (RemesaType) u.unmarshal(bais);
// on-demand validation
Validator v = jc.createValidator();
v.setEventHandler(new EventHandler(log));
boolean isValid = v.validateRoot( remesa );
----- Original Message -----
From: Jesús Ferrero
To: JAXB-INTEREST_at_JAVA.SUN.COM
Sent: Friday, June 13, 2003 12:50 PM
Subject: Long processing time
Hi,
I have 7 different XSD schemas and have sucessfully created the Java classes using xjc. When I give an XML to the unmarshaller in order to get the instance of the objects, all of them do the job in less than 1 sec. but one. This one return the instance after 72 secs of processing time.
I think that the problem is the validation. If i set validation to "false" it does the job fast, but i *need* validation. I have tried to validate the xml against the xsd using Xerces, and it does the job well (in less than 1 sec).
I have tried jaxb 1.0 and jaxb 1.0.1 with the same result. I am now trying to simplify the xsd, but ¿could someone give me a clue about this problem?
- The invocation to the unmarshaller:
String xml = "..."; // This is the xml document in a string
String enc = "ISO-8859-1";
byte[] bytes = xml.getBytes(enc);
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
JAXBContext jc = JAXBContext.newInstance("jfactory.project.xml.modelo"+MODELO);
Unmarshaller u = jc.createUnmarshaller();
u.setValidating(true);
u.setEventHandler(new EventHandler(log));
remesa = (RemesaType) u.unmarshal(bais);
- The validation made with Xerces 2.4.0
parser = new DOMParser();
setFeature("
http://xml.org/sax/features/validation", true);
setFeature("
http://apache.org/xml/features/validation/schema",true);
setFeature("
http://apache.org/xml/features/validation/schema-full-checking",true);
setProperty("
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",xsdName);
parser.setErrorHandler (this);
parser.parse(new InputSource(new StringReader(xml)));
Thanks in advance
-----------------------------------
Jesús Ferrero
TB·Solutions
Desarrollo Web Factory
ferreroj_at_tb-solutions.com
tlf: +34 976 701 600
fax: +34 976 701 601
web:
http://www.tb-solutions.com
-----------------------------------