Код: Выделить всё
public void validateAgainstScheme(String xmlContent, String xsdLocation) throws SAXException, IOException
{
Objects.requireNonNull(xmlContent);
Objects.requireNonNull(xsdLocation);
URL resource = getClass().getClassLoader()
.getResource(xsdLocation);
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(new Source[]
{
new StreamSource(String.valueOf(resource))
});
Validator validator = schema.newValidator();
validator.validate(new StreamSource(new StringReader(xmlContent)));
}
Код: Выделить всё
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
schemaFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
Код: Выделить всё
schemaFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
Код: Выделить всё
Error parsing load rule: schema_reference: Failed to read schema document 'MyRule.xsd', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.
Я абсолютно не могу найти какое-либо решение в Интернете и буду признателен за любую помощь. как проверить XML на соответствие XSD, используя файлы из ресурсов в Java способом сохранения XXE.
Подробнее здесь: https://stackoverflow.com/questions/787 ... sing-error