I am very new to the scalaxb library and have used JAXB in the past with Java. Now that I am using more scala I found this library and have been very impressed with its functionality.
I am developing an application for a system that will need to process an inbound XML stream. I currently have scalaxb working where I can create an object by using scalaxb.fromXML[SomeClass](xmlElement).
My question is what is the best way I can match the XML element to the class it belongs with. I am thinking a case statement, but what is the cleanest way to do this?
For example.. lets say the following XML element comes in... which is 1 of a couple dozen different elements/classes
val xmlStream = <Person>
<firstname>john</firstname>
<lastname>smith</lastname>
</Person>
xmlStream match {
Not_Sure_What_To_Match => scalaxb.fromXML[Person](xmlStream)
... other XML elements...
}
Does anyone have any suggestions on how I can take my xmlStream and match it to a class? I know in JAXB there was a method i think getDelclaredType that you could use to return the Class the XML belonged to.
Thank you for any suggestions.