eed3si9n / scalaxb

scalaxb is an XML data binding tool for Scala.
http://scalaxb.org/
MIT License
337 stars 154 forks source link

MusicXML does not yield valid scala code #236

Closed choeger closed 10 years ago

choeger commented 10 years ago

I just obtained the MusicXML xsd from http://www.musicxml.com/for-developers/ and scalaxb 1.1.2 does not yield valid scala code.

One problem:

    <xs:complexType name="barline">
        <xs:sequence>
            <xs:element name="bar-style" type="bar-style-color" minOccurs="0"/>
            <xs:group ref="editorial"/>
            <xs:element name="wavy-line" type="wavy-line" minOccurs="0"/>
            <xs:element name="segno" type="empty-print-style-align" minOccurs="0"/>
            <xs:element name="coda" type="empty-print-style-align" minOccurs="0"/>
            <xs:element name="fermata" type="fermata" minOccurs="0" maxOccurs="2"/>
            <xs:element name="ending" type="ending" minOccurs="0"/>
            <xs:element name="repeat" type="repeat" minOccurs="0"/>
        </xs:sequence>
        <xs:attribute name="location" type="right-left-middle" default="right"/>
        <xs:attribute name="segno" type="xs:token"/>
        <xs:attribute name="coda" type="xs:token"/>
        <xs:attribute name="divisions" type="divisions"/>
    </xs:complexType>

Yields a case class:

case class Barline(baru45style: Option[generated.Baru45styleu45color] = None,
  editorialSequence2: generated.EditorialSequence,
  wavyu45line: Option[generated.Wavyu45line] = None,
  segno: Option[generated.Emptyu45printu45styleu45align] = None,
  coda: Option[generated.Emptyu45printu45styleu45align] = None,
  fermata: Seq[generated.Fermata] = Nil,
  ending: Option[generated.Ending] = None,
  repeat: Option[generated.Repeat] = None,
  location: generated.Rightu45leftu45middle,
  segno: Option[String] = None,
  coda: Option[String] = None,
  divisions: Option[BigDecimal] = None) extends Musicu45dataOption1

Obviously this wont compile due to the double fields segno and coda.

eed3si9n commented 10 years ago

If you're using the command line tool there's an option called --attribute-prefix. For sbt-scalaxb it's

attributePrefix in scalaxb in Compile := Some("attr")