Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to map attributes from the http://www.w3.org/2001/XMLSchema-instance namespace #358

Open
ewirch opened this issue Aug 22, 2019 · 4 comments

Comments

@ewirch
Copy link

ewirch commented Aug 22, 2019

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"])

@cowtowncoder
Copy link
Member

That might make sense as an improvement, even though core XML specification actually says nothing about this namespace (since it was added later on in XML Schema), and XML Schema being an optional part of XML processing. But since these attributes are widely used, yes, it would probably make sense to gracefully ignore them.

Question is just... are there are any cases where user might want to bind them? Or can they be just dropped. There is another issue to make use of xsi:nil attribute, so this could be handled as part of that issue.

@cowtowncoder
Copy link
Member

Note: reading of xsi:nil implemented (#354), writing planned to be added (optional), #360.

@henrik242
Copy link

I assume #354 (comment) is related to this?

@cowtowncoder
Copy link
Member

@henrik242 possibly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants