scalaxb and multiple groups

214 Views Asked by At

Using scalaxb 1.1.2 (http://scalaxb.org) on MusicXML (http://www.musicxml.com/for-developers/), I got the following snippet:

<xs:complexType name="part-list">
    <xs:sequence>
        <xs:group ref="part-group" minOccurs="0" maxOccurs="unbounded"/>
        <xs:group ref="score-part"/>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:group ref="part-group"/>
            <xs:group ref="score-part"/>
        </xs:choice>
    </xs:sequence>
</xs:complexType>

This leads to a illegal inheritance:

  trait DefaultGeneratedPartu45listFormat extends scalaxb.ElemNameParser[generated.Partu45list] 
    with GeneratedPartu45groupGroupFormat 
    with GeneratedScoreu45partGroupFormat 
    with GeneratedPartu45groupGroupFormat {

    ...    
  }

As you can see, the double inheritance of GeneratedPartu45groupGroupFormat will make the compile unhappy.

So I have two questions:

  1. Is there a way to workaround this issue by changing the XSD to something equivalent that scalaxb understands?

  2. Is there a way to caonfigure scalaxb to handle that issue gratefully?

1

There are 1 best solutions below

0
On

I am currently interested in getting the XML parser to work, so I was interested in some XSD hack that allows me to do so ;).

Here's a simple substitution you could do to parse the grammar that compiles:

<xs:complexType name="part-list">
  <xs:choice maxOccurs="unbounded">
    <xs:group ref="part-group" />
    <xs:group ref="score-part" />
  </xs:choice>
</xs:complexType>

Once I come to provide a small piece of XML that triggers this bug, I will open an issue for sure.

Here's a quick sample XSD that can reproduce the issue:

<xs:schema targetNamespace="http://www.example.com/music"
        elementFormDefault="qualified"
        xmlns="http://www.example.com/music"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:music="http://www.example.com/music">
  <xs:complexType name="part-list">
      <xs:sequence>
          <xs:group ref="part-group" minOccurs="0" maxOccurs="unbounded"/>
          <xs:group ref="score-part"/>
          <xs:choice minOccurs="0" maxOccurs="unbounded">
              <xs:group ref="part-group"/>
              <xs:group ref="score-part"/>
          </xs:choice>
      </xs:sequence>
  </xs:complexType>

  <xs:group name="part-group">
    <xs:sequence>
      <xs:element name="part" type="xs:string"/>
    </xs:sequence>
  </xs:group>

  <xs:group name="score-part">
    <xs:sequence>
      <xs:element name="score" type="xs:string"/>
    </xs:sequence>
  </xs:group>
</xs:schema>

Please file an issue on Github.