Stephen Bash wrote:
> Andy-
>
> Hm... If the PointError objects are coming from a get method in the
> Point class, things might get a little complicated. You could try
> your mapping, though I don't know if location can use a construct like
> "../" (there may be a construct it will honor, but it would require
> looking through the code to determine how the location attribute is
> parsed). I hadn't thought about it before, but location probably
> SHOULD use XPath, but I agree with you that I don't think it does (it
> may use portions of the spec, but I don't think it implements the full
> spec).
I tried setting point.field[name=errors].bind-xml[location] = "../pointerrors"
(if that makes sense) just to see what would happen. Marshalling doesn't
complain, but will build an XML structure like this:
<point>
<..>
<pointerrors>
<pointerror ... />
</pointerrors>
</..>
</point>
Unmarshalling this gives an XML parsing error, for obvious reasons! So the
location does understand "foo/bar/baz" type structures, but doesn't understand
that ".." means "walk back up the tree". Does this count as a bug? Being able
to handle that more general type of location reference would be very useful,
especially if it's not that hard to implement (I don't know what goes on inside
this bit of Castor!). Anyway, now we know :-)
> In your case what is
> lacking is the larger class that contains both the Points and the
> PointErrors as top level classes. Possibly your marshaling code could
> extract the PointErrors and pack them into some Collection along with
> the Points before marshaling. That would probably be easier than
> coding up the XSLT (though that probably depends on a lot of factors).
What worries me there is that the relation is really hierarchical and I
wouldn't want Castor to try and unmarshall the PointErrors before the Points
have been built. I think XSLT (or just using JDOM to move some elements around)
might be the more robust way... unless the location ".."-fix would be easy?
Thanks again,
Andy
--
Andy Buckley: CEDAR @ IPPP, Durham
Work: www.cedar.ac.uk
www.insectnation.org
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email