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

extending foreign type with optional xs:sequence generates bad code #196

Closed
eed3si9n opened this Issue Feb 24, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@eed3si9n
Owner

eed3si9n commented Feb 24, 2013

steps

  1. prepare a schema in namespace A with a complex type with an optional sequence.
  <xs:complexType name="ForeignBaseType">
    <xs:sequence minOccurs="0">
      <xs:element name="string1" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
  1. prepare another schema in namespace B with a complex type extending b:ForeignBaseType.
  <xs:complexType name="ForeignExtensionTest">
    <xs:complexContent>
      <xs:extension base="b:ForeignBaseType">
        <xs:sequence minOccurs="0">
          <xs:element name="person1" type="gen:Person" />
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
  1. compile them.

problem

  1. it generates a parser that uses wrong fully qualified name for the sequence.
  trait DefaultGeneralForeignExtensionTestFormat extends scalaxb.ElemNameParser[general.ForeignExtensionTest] {
    val targetNamespace: Option[String] = Some("http://www.example.com/general")

    override def typeName: Option[String] = Some("ForeignExtensionTest")

    def parser(node: scala.xml.Node, stack: List[scalaxb.ElemName]): Parser[general.ForeignExtensionTest] =
      phrase(opt(((scalaxb.ElemName(Some("http://www.w3.org/2005/05/xmlmime"), "string1"))) ^^ 
        { case p1 => general.ForeignBaseTypableSequence1(scalaxb.fromXML[String](p1, scalaxb.ElemName(node) :: stack)) }) ~ 
      opt(((scalaxb.ElemName(Some("http://www.example.com/general"), "person1"))) ^^ 
        { case p1 => general.ForeignExtensionTestSequence1(scalaxb.fromXML[general.Person](p1, scalaxb.ElemName(node) :: stack)) }) ^^
      { case p1 ~ p2 =>
      general.ForeignExtensionTest(p1,
        p2) })

    def writesChildNodes(__obj: general.ForeignExtensionTest, __scope: scala.xml.NamespaceBinding): Seq[scala.xml.Node] =
      Seq.concat(__obj.foreignbasetypablesequence1 map { scalaxb.toXML[xmlmime.ForeignBaseTypableSequence1](_, None, Some("foreignbasetypablesequence1"), __scope, false) } getOrElse {Nil},
        __obj.foreignextensiontestsequence1 map { scalaxb.toXML[general.ForeignExtensionTestSequence1](_, None, Some("foreignextensiontestsequence1"), __scope, false) } getOrElse {Nil})

  }

expectation

the parser correctly uses b.ForeignBaseTypableSequence1.

@eed3si9n eed3si9n closed this in 210cb08 Mar 1, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment