Allow skipping attributes from the http://www.w3.org/2001/XMLSchema-instance namespace (with new XmlReadFeature.SKIP_UNKNOWN_XSI_ATTRIBUTES) (original) (raw)

Attributes from the http://www.w3.org/2001/XMLSchema-instance namespace are meant to be consumed by the XML parser. XML containing schema references is currently unparsable by Jackson:

class Test {
    public static void main(String[] args) throws IOException {
        var mapper = new XmlMapper();

        mapper.readValue(
            "<dto xmlns=\"http://SomeNamespace\""
                + "   xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""
                + "   xsi:schemaLocation=\"http://SomeNamespace"
                + "                       http://SomeNamespace/schema.xsd\" >"
                + " <value>hello</value>"
                + "</dto>",
            Dto.class
        );
    }

    static class Dto {
        public String value;
    }
}

Fails with

Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "schemaLocation" (class com.smarthost.api.components.offers.email.Test$Dto), not marked as ignorable (one known property: "value"])