Hi all,
I'm trying to generate an XML from a Class file. Since the XML attributes
have different name from Java fields I have to use a mapping file.
Unfortunately the XML generated stays the same even if I use the mapping
file.
Simple example:
public class Note implements Serializable {
long noteId;
String actor;
// getter and setter methods here
}
<mapping>
<class name="Note">
<map-to xml="note" />
<field name="actor" type="java.lang.String">
<bind-xml name="manager" node="element" />
</field>
</class>
</mapping>
So I want in this basic example that the field "actor" is displayed in the
XML as "manager".
FileWriter writer = new FileWriter("C:\\cds.xml");
Note note = getNoteFromDB();
Marshaller mar = new Marshaller();
mar.setMapping(mapping);
mar.marshal(note, writer);
Unfortunately the XML generated stays the same, whether or not I use the
mapping file....
<?xml version="1.0" encoding="UTF-8"?>
<note note-id="6099">
<actor>MyBoss</actor>
</note>
Can anybody help me how to do it ?
thanks a lot
francesco
--
View this message in context:
http://www.nabble.com/-Beginner--Mapping-a-class-with-an-XML-file-tp19666353p19666353.html
Sent from the Castor - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email