Skip to content

Commit

Permalink
fixed xs:any ##local. fixes #101
Browse files Browse the repository at this point in the history
  • Loading branch information
eed3si9n committed Oct 26, 2011
1 parent 4cd6551 commit 4a93c6a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
11 changes: 6 additions & 5 deletions cli/src/main/scala/scalaxb/compiler/xsd/Parsers.scala
Expand Up @@ -48,11 +48,12 @@ trait Parsers extends Args with Params {
case Nil => "_ => true"
case "##any" :: Nil => "_ => true"
case "##other" :: Nil => "_.namespace != %s" format (quoteNamespace(schema.targetNamespace))
case _ => (namespaceConstraint.map {
case "##targetNamespace" => quoteNamespace(schema.targetNamespace)
case "##local" => "None"
case x => "Some(%s)".format(x)
}).mkString("List(", ", ", ").contains(_)")
case _ =>
"""x => %s contains x.namespace""" format (namespaceConstraint.map {
case "##targetNamespace" => quoteNamespace(schema.targetNamespace)
case "##local" => "None"
case x => "Some(%s)".format(x)
}).mkString("List(", ", ", ")")
})

buildParserString(if (mixed) "((" + parser + " ^^ (" + converter + ")) ~ " + newline +
Expand Down
16 changes: 9 additions & 7 deletions integration/src/test/resources/GeneralUsage.scala
Expand Up @@ -262,26 +262,28 @@ object GeneralUsage {
*/
def testAny {
println("testAny")
val subject = <foo xmlns="http://www.example.com/general"
val subject = <gen:foo xmlns:gen="http://www.example.com/general"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:o="http://www.example.com/other">
<person1><firstName>John</firstName><lastName>Doe</lastName></person1>
<gen:person1><gen:firstName>John</gen:firstName><gen:lastName>Doe</gen:lastName></gen:person1>
<o:foo xsi:type="xs:int">1</o:foo>
<person2 xsi:nil="true"/>
<person3><firstName>John</firstName><lastName>Doe</lastName></person3>
<local><somethingLocal/></local>
<gen:person2 xsi:nil="true"/>
<gen:person3><gen:firstName>John</gen:firstName><gen:lastName>Doe</gen:lastName></gen:person3>
<o:foo xsi:type="xs:int">1</o:foo>
<o:foo xsi:type="xs:int">1</o:foo>
<o:foo xsi:type="xs:int">1</o:foo><o:foo xsi:type="xs:int">1</o:foo>
<person5><firstName>John</firstName><lastName>Doe</lastName></person5>
<person5><firstName>John</firstName><lastName>Doe</lastName></person5>
</foo>
<gen:person5><gen:firstName>John</gen:firstName><gen:lastName>Doe</gen:lastName></gen:person5>
<gen:person5><gen:firstName>John</gen:firstName><gen:lastName>Doe</gen:lastName></gen:person5>
</gen:foo>
val obj = fromXML[AnyTest](subject)

def check(obj: Any) = obj match {
case AnyTest(
Person("John", "Doe"),
DataRecord(O, Some("foo"), 1), // Single
DataRecord(None, Some("local"), _), // Local
DataRecord(NS, Some("person2"), None),
Some(Person("John", "Doe")),
Some(DataRecord(O, Some("foo"), 1)), // optional
Expand Down
1 change: 1 addition & 0 deletions integration/src/test/resources/general.xsd
Expand Up @@ -156,6 +156,7 @@
<xs:sequence>
<xs:element name="person1" type="gen:Person"/>
<xs:any namespace="##other" processContents="lax"/>
<xs:any namespace="##local" processContents="lax"/>
<xs:choice>
<xs:element name="person2" nillable="true" type="gen:Person"/>
<xs:any namespace="##other" processContents="lax"/>
Expand Down

0 comments on commit 4a93c6a

Please sign in to comment.