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

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

Open
hongwei1 opened this issue Mar 8, 2021 · 1 comment

Comments

@hongwei1
Copy link

hongwei1 commented Mar 8, 2021

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)
@hongwei1
Copy link
Author

hongwei1 commented Mar 8, 2021

it is relevant to #402 , please fix it

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

1 participant