We are dealing with a rather complex XML schema (HR-XML) and hoping to use an xpath based mapping approach to unmarshall to our locally defined domain objects. We tried Simple but ran into issues. We've recently tried MOXy with a little better luck but have hit an issue with predicate support. I'm trying to confirm if MOXy supports the predicate that I think I need to use. What I need to do is retrieve the value of one element based on a sibling element's value.
When this is executed I get nulls like it isn't selecting correctly. Has anybody done similar? Maybe there is another issue?
Example XML:
<person>
<communication>
<address>
<street>101 First St.</street>
<city>Whoville</city>
<state>CA</state>
</address>
</communication>
<communication>
<channelcode>email</channelcode>
<uri>[email protected]</uri>
</communication>
<communication>
<channelcode>telephone</channelcode>
<usecode>mobile</usecode>
<dialnumber>555-555-5555</dialnumber>
</communication>
</person>
Example Obj:
public class Person
{
private String email;
private Address homeAddress;
private String homePhone;
...
Example xml-bindings.xml fragment:
<java-types>
<java-type name="Person">
<xml-root-element name="person">
<java-attributes>
<xml-element java-attribute="email" xml-path="communication/uri[../channelcode/text()='email']/text()" />
<xml-element java-attribute="homePhone" xml-path="communication[channelcode/text()='telephone']/dialnumber/text()" />
<xml-element java-attribute="homeAddress" xml-path="communication/Address" />
</java-attributes>
</java-type>
...