eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
202 stars 110 forks source link

[Regress] Namespace inheritance by children element #1782

Open MaximValeev opened 8 months ago

MaximValeev commented 8 months ago

For now in version jaxb-runtime-4.0.4 nested elements don't inherit the root element namespace.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {

})
@XmlRootElement(name = "ResponseType", namespace = "http://www.anyurl.com/wsdl/")
public class ResponseType {

    @XmlElement(required = true)
    protected String status;
    @XmlElement(required = true)
    protected String message;

Status and message will get "" namespace instead of XmlRootElement's namespace so i get unmarshalleing error if try to unmarshall:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://www.anyurl.com/wsdl/">
    <soapenv:Header/>
    <soapenv:Body>
        <wsdl:ResponseType>
            <wsdl:status>01</wsdl:status>
            <wsdl:message>success</wsdl:message>
        </wsdl:ResponseType>
    </soapenv:Body>
</soapenv:Envelope>

Unmarshalling Error: unexpected element (uri:"http://www.anyurl.com/wsdl/", local:"status"). Expected elements are <{}message>,<{}status>

There was no this issue in the 4.0.3 version.

This is the reason https://github.com/eclipse-ee4j/jaxb-ri/commit/2269a1d80914221a1be73026b7c2e94bb0a4f11f#r135406382

What is the correct behaviour? I have been supposing that child elements should inherit their parents namespace.