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).
As far as extending the example to multiple classes, it does work. When I wrote the HOWTO I was being a little lazy and didn't want to code up multiple interdependent classes. A simple example is a heterogeneous ArrayList where some of the classes reference others. Marshaling that ArrayList will produce the desired effect if the mappings define identities and references. 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). HTH, Stephen On 12/11/06, Andy Buckley <[EMAIL PROTECTED]> wrote:
Stephen Bash wrote: > Andy- > > Based on the snippet you list here, I don't think you NEED to > transform the document (you may find it makes your life easier, but it > may not be required). I think you'll want to look at the following > HOWTO: > > http://castor.org/how-to-use-references-in-xml.html > > Let us know if you have more questions. Hi Stephen, Thanks very much for this reference (sorry)! It looks almost exactly like what I need, but I'm not clear if I can extend it to my scenario where the references are between different classes. The way that the Pointerror objects are obtained will be through the point.getErrors() method, so in this case there actually *is* a hierarchy... I just don't want it displayed as such! The only way I can imagine this working would be if I can do something like this in the mapping: <class name="Point" identity="PointId"> <field name="PointId"> <bind-xml name="pointId" node="attribute"/> </field> ... <field name="Errors" type="PointError" collection="sortedset"> <bind-xml name="pointerror" node="element" location="../pointerrors"/> </field> </class> ... <class name="PointError"> <field name="Point"> <bind-xml name="pointId" node="attribute" reference="true"/> </field> </class> (i.e. use the class[identity] and bind-xml[reference] attributes as in the example, but also use "../" in the bind-xml[location] attribute for point.errors) Is this possible, or will I have to fall back to less clever mechanisms? I'm guessing that the location attribute doesn't handle full-on XPath statements, but I could be wrong :-) 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
--------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

