Hi,
I have a tricky use case, hope someone can make things clearer for me :-).
I'm attempting to use the XMLFilterImpl to ignore certain kinds of errors
that occur during unmarshalling of my XML. This is based on Kohsuke's
'partial-unmarshalling' sample. I also set a ValidationEventHandler
implementation as my event handler in which I return true to ensure that
parsing does not stop on account of errors.
Basically, I do the following:
// create a non-validating XMLReader..
XMLReader xmlReader = createXMLReader(false);
// the ContentHandler for this document is the
MyXMLDocSplitter
MyXMLDoc docSplitter = new
MyXMLDocSplitter(rootElementName, ignoreElementList, new
MyValidationEventHandler());
// set the splitter as the content handler in the
XMLReader instance
xmlReader.setContentHandler(docSplitter);
// parse the document..
xmlReader.parse(new
File(fileName).toURL().toExternalForm());
Specifically, in certain fields in my XML a string value appears where an
integer is defined in the schema. On receiving errors on these elements I
ignore the error and return true in my ValidationEventHandler
implementation. However, I get an UnmarshalException because endElement
event on the same element throws the exception below.
Can someone tell me how I can ignore this error and continue processing
the rest of my XML?
Exception Message : XML Parsing error: Failed to parse XML from file:
d:\dist\negotiate\test\bin\import.xml
Caught Exception : org.xml.sax.SAXException
Current Exception : org.xml.sax.SAXException
Stack Trace :
javax.xml.bind.UnmarshalException: Unexpected end of element
{
http://srm.i2.com/neg}:biddingType
at
com.i2.srm.integration.gen.runtime.SAXUnmarshallerHandlerImpl.handleEvent(SAXUnmarshallerHandlerImpl.java:551)
at
com.i2.srm.integration.gen.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:148)
at
com.i2.srm.integration.gen.runtime.AbstractUnmarshallingEventHandlerImpl.reportError(AbstractUnmarshallingEventHandlerImpl.java:145)
at
com.i2.srm.integration.gen.runtime.AbstractUnmarshallingEventHandlerImpl.unexpectedLeaveElement(AbstractUnmarshallingEventHandlerImpl.java:162)
at
com.i2.srm.integration.gen.runtime.AbstractUnmarshallingEventHandlerImpl.leaveElement(AbstractUnmarshallingEventHandlerImpl.java:72)
at
com.i2.srm.integration.gen.negotiate.impl.RFxHeaderBidTypeImpl$Unmarshaller.leaveElement(RFxHeaderBidTypeImpl.java:5754)
at
com.i2.srm.integration.gen.runtime.SAXUnmarshallerHandlerImpl.endElement(SAXUnmarshallerHandlerImpl.java:146)
at
org.iso_relax.verifier.impl.ForkContentHandler.endElement(ForkContentHandler.java:81)
at
org.xml.sax.helpers.XMLFilterImpl.endElement(XMLFilterImpl.java:595)
at
com.i2.srm.integration.schemautil.MyXMLDocSplitter.endElement(MyXMLDocSplitter.java:265)
at
weblogic.apache.xerces.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:585)
at
weblogic.apache.xerces.impl.XMLNamespaceBinder.handleEndElement(XMLNamespaceBinder.java:898)
at
weblogic.apache.xerces.impl.XMLNamespaceBinder.endElement(XMLNamespaceBinder.java:644)
at
weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1008)
at
weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1469)
at
weblogic.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:329)
at
weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:525)
at
weblogic.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:581)
at
weblogic.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
at
weblogic.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1175)
at
weblogic.xml.jaxp.WebLogicXMLReader.parse(WebLogicXMLReader.java:135)
at
weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:138)
at
weblogic.xml.jaxp.RegistryXMLReader.parse(RegistryXMLReader.java:150)
at
com.i2.srm.integration.schemautil.SchemaUtil.unmarshalElement(SchemaUtil.java:75)
at
com.i2.srm.neg.txnserver.exim.ImportXMLContext.getRFxHeaderBid(ImportXMLContext.java:115)
at
com.i2.srm.neg.txnserver.exim.session.ImportTestBean.testUnmarshal(ImportTestBean.java:35)
at
com.i2.srm.neg.txnserver.exim.session.ImportTest_5pp5a6_EOImpl.testUnmarshal(ImportTest_5pp5a6_EOImpl.java:46)
at
com.i2.srm.neg.txnserver.exim.session.ImportTest_5pp5a6_EOImpl_WLSkel.invoke(Unknown
Source)
at
weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)
at
weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)
at
weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)
at
weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)
at
weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)
at
weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)
at
weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Exception Message : Unexpected end of element
{
http://srm.i2.com/neg}:biddingType
End Exception Trace :
============ End Rightworks Error =========
Thanks in advance,
Gagan