highsource / jaxb2-basics

Useful plugins and tools for JAXB2.
BSD 2-Clause "Simplified" License
109 stars 54 forks source link

Simplifying element (rather than type) results in 'Unable to honor this as-element-property customization. It is attached to a wrong place, or its inconsistent with other bindings.'. #164

Open dolgorukee opened 1 year ago

dolgorukee commented 1 year ago

`<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://www.example.com/schema-a" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:schema-b="http://www.example.com/schema-b" targetNamespace="http://www.example.com/schema-a" elementFormDefault="qualified">

<xsd:import schemaLocation="schema-b.xsd" namespace="http://www.example.com/schema-b"/>

<xsd:complexType name="exampleType">
    <xsd:sequence>
        <xsd:element name="property-a" type="xsd:positiveInteger" minOccurs="0"/>
        <xsd:element ref="schema-b:example-element" minOccurs="0"/>
    </xsd:sequence>
</xsd:complexType>

</xsd:schema> `

`<?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns="http://www.example.com/schema-b" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/schema-b" elementFormDefault="qualified">

<xsd:element name="example-element" >
    <xsd:complexType>
        <xsd:sequence>
            <xsd:choice>
                <xsd:sequence>
                    <xsd:element name="element-a" type="xsd:string"/>
                    <xsd:element name="element-b" type="xsd:string" minOccurs="0"/>
                </xsd:sequence>
                <xsd:element name="element-b" type="xsd:string"/>
            </xsd:choice>
            <xsd:element name="blah" type="xsd:string"/>
        </xsd:sequence>
    </xsd:complexType>
</xsd:element>

</xsd:schema> `

How to simplify the choice in example-element. Adding binding or directly in the schema results in the error from the title.

laurentschoelens commented 1 year ago

Need to check but seems to be duplicate of https://github.com/highsource/jaxb2-basics/issues/133