Как создать класс из элемента с любым complexType? - PullRequest
0 голосов
/ 05 июля 2019
           <xs:element name="CustomAttributes" minOccurs="0">
                <xs:complexType>
                    <xs:sequence>
                        <xs:any/>
                    </xs:sequence>
                </xs:complexType>
            </xs:element>

xjc генерирует класс:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
        "any"
})
public static class CustomAttributes {

    @XmlAnyElement(lax = true)
    protected Object any;
}

Я пытался разобрать этот JSON в XML

"custom_attributes" :{
    "attributes":{
        "aaa":"2",
        "bbb": "eee"
    }
 }

Я создал другую схему, чтобы она заработала.

<xs:element name="Attributes">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="aaa" type="xs:string" minOccurs="0" />
            <xs:element name="bbb" type="xs:string" minOccurs="0"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

И сгенерировать класс, но разбор не работает

...