I am using moxy to read in given xml with given schema (see attachments!). Validation in Eclipse passes but online or using java/moxy fails with
org.xml.sax.SAXParseException; lineNumber: 1353; columnNumber: 40; src-resolve: Cannot resolve the name 'xenc:EncryptedData' to a(n) 'element declaration' component.
(what a line number??)
In Java it seems to make no difference if only one schema is loaded or all 3 schemas are loaded - the error persists.
My test code for this use case looks like that at the moment:
@Test
public void test() throws Exception {
Unmarshaller um;
JAXBContext jaxbContext = JAXBContext
.newInstance("...generatedClasses.invoice.general430.request");
um = jaxbContext.createUnmarshaller();
InputStream mainSchemaIs = this.getClass().getResourceAsStream("/xsd/" + "generalInvoiceRequest_430.xsd");
InputStream encodeSchemaIs = this.getClass().getResourceAsStream("/xsd/" + "xenc-schema.xsd");
InputStream sigSchemaIs = this.getClass().getResourceAsStream("/xsd/" + "xmldsig-core-schema.xsd");
InputStream xmlIs = SingleTests.class.getResourceAsStream("/430_requests/dentist_ersred_TG_430.xml");
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new Source[] { new StreamSource(mainSchemaIs), new StreamSource(encodeSchemaIs), new StreamSource(sigSchemaIs) });
um.setSchema(schema);
// XMLInputFactory xif = XMLInputFactory.newFactory();
// xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
um.unmarshal(new StreamSource(xmlIs), ...generatedClasses.invoice.general430.request.RequestType.class);
}
So how to get this xml validated?