I have build my own XML schema for invoice events and are using JAXB2 to parse an XML document based upon this XML schema.
The following piece of code works fine, but does not handle very large files:
Then I tried using StAX with JAXB in order to stream read the XML file.
Soluton1:
Solution2:
Both solutions with StAX gives me the following error:
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 15; cvc-elt.1: Cannot find the declaration of element 'invoiceEvent'.]
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.handleStreamException(UnmarshallerImpl.java:419)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:356)
at com.sun.xml.internal.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:326)
at Invoice.main(Invoice.java:90)
Caused by: org.xml.sax.SAXParseException; lineNumber: 3; columnNumber: 15; cvc-elt.1: Cannot find the declaration of element 'invoiceEvent'.
My XML Schema file:
The first few lines of my XML file: