The solution on this post suggests using an XMLAdapter to get around this problem. I've repeated part of the question below for convenience.
--Network.xml-- <Network> <Nodes> <Node id="ROD" /> <Node id="KFI" /> <Node id="JND" /> </Nodes> <Arcs> <Arc fromNode="ROD" /> <Arc fromNode="JND" /> </Arcs> </Network> ---------
Using @XmlID and @XmlIDREF annotations, this can be unmarshalled fine.
--NetworkInputs.xml-- <NetworkInputs> <Flows> <Flow toNode="JND" /> <Flow toNode="ROD" /> </Flows> </NetworkInputs> ------
There's no connection between Network and NetworkInputs that allows JAXB to "see" the nodes that exist in Network. I want my Flow objects to point to the correct Node in the Network class.
WHAT I WANT: 1 - I am hoping to find a more general solution, without having to write an adapter for each individual case.
2- Another reason for not writing an adapter is because, I cannot gaurantee that the Network.xml file will be unmarshalled before the NetworkInputs.xml file.
No comments:
Post a Comment