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

direct restriction of xs:anySimpleType does not round trip without xsi:type #203

Closed
eed3si9n opened this Issue Mar 13, 2013 · 0 comments

Comments

Projects
None yet
1 participant
@eed3si9n
Owner

eed3si9n commented Mar 13, 2013

steps

  1. compile a schema with a complex type that restricts xs:anySimpleType.
    <xs:complexType name="anySimpleTypeRestriction">
      <xs:simpleContent>
        <xs:restriction base="xs:anySimpleType">
          <xs:simpleType>
            <xs:union>
              <xs:simpleType>
                <xs:restriction base="xs:unsignedShort">
                  <xs:enumeration value="1"/>
                  <xs:enumeration value="2"/>
                </xs:restriction>
              </xs:simpleType>
              <xs:simpleType>
                <xs:restriction base="xs:unsignedShort">
                  <xs:enumeration value="0"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:union>
          </xs:simpleType>
          <xs:anyAttribute namespace="##any" processContents="lax"/>
        </xs:restriction>
      </xs:simpleContent>
    </xs:complexType>
  1. try round tripping an XML document that does not have xsi:type attribute:
    def testSimpleAnyTypeRestriction {
      println("testSimpleAnyTypeRestriction")
      val subject = <foo xmlns="http://www.example.com/general"
        xmlns:gen="http://www.example.com/general"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:xs="http://www.w3.org/2001/XMLSchema">1</foo>
      val obj = fromXML[AnySimpleTypeRestriction](subject)

      def check(obj: Any) = obj match {
          case AnySimpleTypeRestriction(DataRecord(_, _, <foo>1</foo>), _) =>
          case _ => error("match failed: " + obj.toString)
        }
      check(obj)
      val document = toXML[AnySimpleTypeRestriction](obj, "foo", scope)
      println(document)
      check(fromXML[AnySimpleTypeRestriction](document))
    }

problem

  1. within <foo></foo> another &lt;foo&gt;1&lt;/foo&gt; gets nested.

expectation

  1. round trips correctly as <foo>1</foo>.

note

This is due to simpleContentString generating Seq(scala.xml.Text(__obj.value.value.toString)). Discovered while debugging #200.

@eed3si9n eed3si9n closed this in 7f6ac49 Mar 13, 2013

eed3si9n added a commit that referenced this issue Apr 21, 2013

eed3si9n added a commit that referenced this issue May 20, 2013

eed3si9n added a commit that referenced this issue May 26, 2013

eed3si9n added a commit that referenced this issue Jul 18, 2013

eed3si9n added a commit that referenced this issue Jul 28, 2013

eed3si9n added a commit that referenced this issue Sep 12, 2013

eed3si9n added a commit that referenced this issue Nov 8, 2014

eed3si9n added a commit that referenced this issue Jul 7, 2016

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