This may be more of an XML/XSD question, but since I'm using JAXB...
...is there a way to make sure an XML string matches a schema element,
and is not just valid against the whole schema.
For example, in my schema I have two elements <foo /> and <bar />. An
element of either type will validate against the schema. But, if I
have a method saveFoo(xmlString) which takes this string, how can I
ensure that xmlString is an element "foo" and not "bar"?
The not very imaginative approach would be to unmarshall it into an
object to see what type it is...that is a lot of overhead. Since I'm
saving it into the database, all I need is the XML in the string
form...