Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation error (type mismatch) on xs:choice with just 1 element #583

Open
alexandru opened this issue Jan 26, 2022 · 1 comment
Open

Comments

@alexandru
Copy link

We have an XML with an xs:choice that has only one element in it, like this:

    <xs:complexType name="CreditorReferenceType1Choice">
        <xs:sequence>
            <xs:choice>
                <xs:element name="Cd" type="DocumentType3Code"/>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>

Unfortunately Scalaxb is throwing a compilation error on the generated code:

[error] .../target/scala-2.13/src_managed/main/sbt-scalaxb/.../generated/xmlprotocol.scala:3841:106: type mismatch;
[error]   DataRecord[String|DocumentType3Code]
[error]       ...generated.pacs28v1.CreditorReferenceType1Choice(p1) })

To fix it we just have to delete the choice declaration:

    <xs:complexType name="CreditorReferenceType1Choice">
        <xs:sequence>
             <xs:element name="Cd" type="DocumentType3Code"/>
        </xs:sequence>
    </xs:complexType>

But it would be nice if Scalaxb did this for us, as we'd like to use these XSDs without modification. This is a modified standard schema, originally that type had 2 choices, I guess the authors just deleted one of them 🤷‍♂️

@waleedsamy
Copy link

choice element can also has not options as next

<xs:choice/>

I thinks we should not fail in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants