-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hello. Thanks for this awesome library. It has helped me catch many issues in our xml rendering.
I am running into an issue with validation using two xsds with namespaces.
I have setup the assertion like this.
assertThat(result)
.isValidAgainst(vmapXsdSource(), vast3XsdSource())
.and("""
<vmap:VMAP xmlns:vmap="http://www.iab.net/videosuite/vmap" version="1.0"/>
""")
.ignoreWhitespace()
.areIdentical();
The sources are on github.
https://github.com/InteractiveAdvertisingBureau/vmap/blob/5412bbe033ba9573b517619b1b4fa2027987a0d3/xsd/vmap.xsd
https://github.com/InteractiveAdvertisingBureau/vast/blob/f28dbb4768744062fcb638a1859364cdafb3a449/vast3_draft.xsd
vmap.xsd references vast in one location and it is causing me issues.
<xs:complexType name="VASTAdData_type">
<xs:sequence>
<xs:element ref="vast:VAST" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
This is where the sources are created.
private Source vmapXsdSource() {
var source = Input.fromStream(getClass().getResourceAsStream("response_templates/xsd/vmap.xsd")).build();
source.setSystemId("http://www.iab.net/videosuite/vmap");
return source;
}
private Source vast3XsdSource() {
var source = Input.fromStream(getClass().getResourceAsStream("response_templates/xsd/vast3_draft.xsd")).build();
source.setSystemId("http://www.iab.net/videosuite/vast");
return source;
}
I tried setting the system id but it doesn't seem to help. This is the error I now get.
Caused by: org.xml.sax.SAXParseException; systemId: http://www.iab.net/videosuite/vmap; lineNumber: 1; columnNumber: 1; Premature end of file.
The wiki says
when validating a DTD with XMLUnit for Java you may need to set schemaURI to the Public ID of the schema so that XMLUnit's EntityResolver can provide the schema to the parser.
But I'm not sure where schema comes into play when using .isValidAgainst. Is that a different type of Source?
I couldn't find an example of using multiple xsd files to validate xml output.
I can live without validation but it would be nice to have an example of this working somewhere in the documentation.