I want to validate XML files against this schema (that is inside the zip); it imports two other XSD files.
<import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="xmldsig-core-schema.xsd"/>
<import namespace="http://www.w3.org/2001/04/xmlenc#"
schemaLocation="xenc-schema.xsd"/>
The 2 files are also available here:
- http://www.forum-datenaustausch.ch/xmldsig-core-schema.zip
- http://www.forum-datenaustausch.ch/xenc-schema.zip.
On validation, I get this error:
Src-resolve: Cannot Resolve The Name 'xenc:EncryptedData' To A(n) 'element Declaration' Component.
My validation/unmarshalling code looks like this (using moxy as a JAXB provider):
jaxbContext = JAXBContext.newInstance(type.getRequestType().getPackage().getName());
Unmarshaller um = jaxbContext.createUnmarshaller();
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new StreamSource(this.getClass().getResourceAsStream("/xsd/" + type.getXsdName())));
um.setSchema(schema);
root = um.unmarshal(new StreamSource(new ByteArrayInputStream(xmlData)), type.getRequestType());
Before you ask what does the type do: I wrote code that could import all types of invoices from http://www.forum-datenaustausch.ch/. But versions 4.3 and above use the two additional schema files. How can validate the XML files?