Is Your XML Document Valid?
No, as you state the value of the xsi:type
attribute does not correspond to a named complex type in your XML schema.
Should that Matter?
JAXB implementations aim to be very fault tolerant. I couldn't get your example to fail using the default JAXB impl in the latest JDK 1.7 install or EclipseLink JAXB (MOXy):
ErRequest
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="er-request")
public class ErRequest {
}
Demo
import javax.xml.bind.*;
import javax.xml.transform.stream.StreamSource;
public class Demo {
public static void main(String[] args) throws Exception {
JAXBContext jc = JAXBContext.newInstance(ErRequest.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
StreamSource xml = new StreamSource("src/forum22497112/input.xml");
ErRequest erRequest = (ErRequest) unmarshaller.unmarshal(xml);
}
}
Where is the Error Coming From
The error you are getting appears to be a schema validation error:
Error::cvc-elt.4.2: Cannot resolve 'er-request' to a type definition for element 'er-request'
Are you asking JAXB to perform schema validation on the input? JAXB does not do this by default. Since your document is not valid you will have to fix it or register an error listener to ignore it.