eed3si9n / scalaxb

scalaxb is an XML data binding tool for Scala.

Home Page:http://scalaxb.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Critical parsing bug, minOccurs="0" type="xs:anyType" , name: Option[scalaxb.DataRecord[Any]] = None, scalaxb.ParserFailure

hongwei1 opened this issue · comments

usaddress.xsd :

<xs:schema targetNamespace="http://www.example.com/IPO"
        elementFormDefault="qualified"
        xmlns="http://www.example.com/IPO"
        xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:ipo="http://www.example.com/IPO">
  <xs:complexType name="Address">
    <xs:sequence>
      <xs:element minOccurs="0" name="name" type="xs:anyType"/>
      <xs:element name="street" type="xs:string"/>
      <xs:element name="city"   type="xs:string"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="USAddress">
    <xs:complexContent>
      <xs:extension base="ipo:Address">
        <xs:sequence>
          <xs:element name="state" type="xs:string"/>
          <xs:element name="zip"   type="xs:positiveInteger"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

--> mvn generate-sources (scalaxb-maven-plugin, version= 1.8.1, scala.version = 2.12.10)

case class Address(name: Option[scalaxb.DataRecord[Any]] = None,
  street: String,
  city: String) extends Addressable

But when I omit name in the XML file and call as following:

object testXmlFormat extends App {

  val subject: Elem = <shipTo xmlns="http://www.example.com/IPO">
    <street>1537 Paper Street</street>
    <city>Wilmington</city>
  </shipTo>

  val shipTo: Address = scalaxb.fromXML[Address](subject)
  println(shipTo)

}

It shows the strange errors:

Exception in thread "main" scalaxb.ParserFailure: Error while parsing <shipTo xmlns="http://www.example.com/IPO">
      <street>1537 Paper Street</street>
      <city>Wilmington</city>
    </shipTo>: parser error "'{http://www.example.com/IPO}street' expected but {http://www.example.com/IPO}city found" while parsing /{http://www.example.com/IPO}shipTo/{http://www.example.com/IPO}street{http://www.example.com/IPO}city
 ^
	at scalaxb.package$.fromXML(scalaxb.scala:19)
	at obp.testXmlFormat$.delayedEndpoint$obp$testXmlFormat$1(testXmlFormat.scala:16)
	at obp.testXmlFormat$delayedInit$body.apply(testXmlFormat.scala:7)
	at scala.Function0.apply$mcV$sp(Function0.scala:39)
	at scala.Function0.apply$mcV$sp$(Function0.scala:39)
	at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
	at scala.App.$anonfun$main$1$adapted(App.scala:80)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at scala.App.main(App.scala:80)
	at scala.App.main$(App.scala:78)
	at obp.testXmlFormat$.main(testXmlFormat.scala:7)
	at obp.testXmlFormat.main(testXmlFormat.scala)

it is relevant to #402 , please fix it