Created
October 5, 2011 00:23
-
-
Save oluies/1263253 to your computer and use it in GitHub Desktop.
scalaxb xsd:Choice match
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scalaxb.DataRecord | |
val x = scalaxb.fromXML[cusin.bo.MobileSubscriptionServicesAndCustomer](xml) | |
// DataRecord(namespace,type,...) | |
x.Body.bodyoption match { | |
//case DataRecord(a,b,c) => print("\na="+ a + "\nb= " + b + "\nc=" + c) | |
case DataRecord(_,Some("subscription_insert"),_) => println("insert") | |
case DataRecord(_,Some("subscription_update"),_) => println("update") | |
case DataRecord(_,Some("subscription_delete"),_) => println("delete") | |
case DataRecord(a,b,c) => error("invalid choice " + a + b) | |
} | |
// better... typechecked | |
import scalaxb.DataRecord | |
import cusin.bo._ | |
val x = scalaxb.fromXML[cusin.bo.MobileSubscriptionServicesAndCustomer](xml) | |
x.Body.bodyoption match { | |
//case DataRecord(a,b,c) => print("\na="+ a + "\nb= " + b + "\nc=" + c) | |
case DataRecord(_,_,i:Subscription_insert) => println("insert") | |
case DataRecord(_,_,u:Subscription_update) => println("update") | |
case DataRecord(_,_,d:Subscription_delete) => println("delete") | |
case DataRecord(a,b,c) => error("invalid choice " + a + b) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment