Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8134111

Unmarshaller unmarshalls XML element which doesn't have the expected namespace

    Details

    • Subcomponent:
    • Resolved In Build:
      b113
    • Verification:
      Not verified

      Backports

        Description

        XML that contains unqualified to target namespace elements is successfully unmarshalled when elementFormDefault is set to QUALIFIED. Such elements should be ignored by unmarshaller.

        The following code and xml file illustrates this problem:
        Xml to unmarshall (XML_TO_U):
        <tns:root xmlns:tns="http://www.example.org/testSchema/">
        <tns:when>
        <dtime>2015-06-24T13:16:14.933-04:00</dtime>
        </tns:when>
        </tns:root>

        Jaxb context package information file:
        @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.example.org/testSchema/", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
        package testTypes;

        Main method that does unmarshalling:
        context = JAXBContext.newInstance("testTypes");
        unm = context.createUnmarshaller();
        Object o = unm.unmarshal(new InputSource(new StringReader(XML_TO_U)));
        Root r = (Root)o;
        System.out.println("dtime is:"+r.getWhen().getDtime());

        It is expected that dtime should be null:
        "dtime is:null"
        But the code prints:
        "dtime is:2015-06-24T13:16:14.933-04:00"

        JDK9/8 is affected by this issue

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  aefimov Aleksej Efimov
                  Reporter:
                  shadowbug Shadow Bug
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: