javaee / jaxb-v2

Other
211 stars 101 forks source link

Text nodes are not unmarshalled for combination @XmlMixed + @XmlElementRefs + @XmlElementWrapper #1107

Open glassfishrobot opened 7 years ago

glassfishrobot commented 7 years ago

The issue is described here. In particular for the following model element:

@XmlRootElement(name = "any-text")
public class AnyText {

    @XmlElementWrapper(name = "fixed-text", required = true)
    @XmlElementRefs({
        @XmlElementRef(name = "year", namespace = "http://foo.org/", type = JAXBElement.class, required = false),
        @XmlElementRef(name = "title", namespace = "http://foo.org/", type = JAXBElement.class, required = false)
    })
    @XmlMixed
    protected List<Serializable> fixedText = new ArrayList<Serializable>();
...

the hanging text nodes are not unmarshalled/marshalled. Sample XML:

<any-text xmlns="http://foo.org/">
    <fixed-text>The story <title>Alice in Wonderland</title> was printed in <year>1865</year>.</fixed-text>
</any-text>

Sample XSD:

<xs:schema
    jaxb:version="2.0"
    targetNamespace="http://foo.org/"   xmlns:foo="http://foo.org/"     xmlns:xs="http://www.w3.org/2001/XMLSchema"     elementFormDefault="qualified"
>
    <xs:complexType name="fixed-text" mixed="true">
        <xs:choice maxOccurs="unbounded">
            <xs:element name="title" type="xs:string" />
            <xs:element name="year" type="xs:int" />
        </xs:choice>
    </xs:complexType>

    <xs:element name="any-text">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="fixed-text" type="foo:fixed-text" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>
</xs:schema>

Affected Versions

[2.2.8 (JDK 8)]

glassfishrobot commented 7 years ago

Reported by dma_k

glassfishrobot commented 7 years ago

Was assigned to yaroska

glassfishrobot commented 7 years ago

This issue was imported from java.net JIRA JAXB-1107