Hi all

i have a xml document and a list of schemas against which it should validate. I use the xerces contained in the tamburin jdk-17.

My problem is, that xerces does not validate the complete document, but skips element after a certain depth.

Here (XMLSchemaValidator, lines 1919)

// if we are in the content of "skip", then just skip this element // REVISIT: is this the correct behaviour for ID constraints? -NG if (fSkipValidationDepth >= 0) {
    fElementDepth++;
    if (fAugPSVI)
        augs = getEmptyAugs(augs);
    return augs;
}

the elements are skipped...

is there a way to make xerces to really validate the complete document?

Here is my source:

final SchemaFactory schemaFactory 
=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
final String pathPrefix =FilenameUtils.getFullPath(schemaPath);
schemaFactory.setResourceResolver(new LocalLSResolver(pathPrefix));
schemaFactory.setFeature("http://apache.org/xml/features/validation/schema-full-checking",true);

final InputStream schemaUrl = getClass().getResourceAsStream(schemaPath);
final Schema schema =schemaFactory.newSchema(new StreamSource(schemaUrl));

final Validator validator =schema.newValidator();
try {
  validator.validate(new StreamSource(new 
ByteArrayInputStream(xmlFile.getBytes(StandardCharsets.ISO_8859_1))));
}catch (IOException ioe) {
  //...
}

Regards Michael

Reply via email to