Hi Matthew, have you had a look at:
http://castor.codehaus.org/how-to-map-a-hashtable.html Regards Ralf Matthew Wilson schrieb:
Hi, I am trying to unmarshall a Map called "class mappings" in which the keys are Strings and the values are references to objects of type QoSClass which are specified in the same instance document. The relevant parts of the mapping file and instance document are shown below. I have tried many different permutations such as making the MapItem value field an entity, setting it's type to java.lang.Object and using xsi:type, but all produce exceptions similar to following: unable to resolve reference: besteffort{File: [not available]; line: 70; column: 30} at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:740) at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:596) at uk.ac.soton.ecs.mpw104.main.tests.XMLRuleConfigTest.<init>(XMLRuleConfigTest.java:35) at uk.ac.soton.ecs.mpw104.main.tests.XMLRuleConfigTest.main(XMLRuleConfigTest.java:54) Caused by: 1. ValidationException: unable to resolve reference: besteffort I have probably made a silly mistake - could someone point it out for me please? Thanks in advance Matthew Wilson. Mapping file: <class name="uk.ac.soton.ecs.mpw104.actions.QoS.QoSNode" identity="name"> <field name="children" type="uk.ac.soton.ecs.mpw104.actions.QoS.QoSNode" collection="arraylist" set-method="addChild"> <bind-xml auto-naming="deriveByClass" node="element" required="true"/> </field> <field name="name" type="java.lang.String"> <bind-xml name="id" node="attribute"/> </field> <!-- other stuff here --> </class> <class name="uk.ac.soton.ecs.mpw104.actions.QoS.QosFlowAction"> <field name="rootNode" type="uk.ac.soton.ecs.mpw104.actions.QoS.QoSQdisc"> <bind-xml name="root" node="element"/> </field> <field name="classMappings" collection="map"> <bind-xml name="classify"> <class name="org.exolab.castor.mapping.MapItem"><field name="key" type="java.lang.String"> <bind-xml name="classification" node="attribute"/></field> <field name="value"type="uk.ac.soton.ecs.mpw104.actions.QoS.QoSClass"> <bind-xml name="trafficclass" reference="true"node="attribute"/> </field> </class> </bind-xml> </field></class><class name="uk.ac.soton.ecs.mpw104.actions.QoS.QoSClass" extends="uk.ac.soton.ecs.mpw104.actions.QoS.QoSNode"> <map-to xml="class"/> </class> Instance document: <Action xsi:type="java:uk.ac.soton.ecs.mpw104.actions.QoS.QosFlowAction"> <root dev="eth0" type="htb"> <parameter name="default" value="30"/> <class type="htb"><class type="htb" id="besteffort"><!-- stuff here --> </class> </class> </root> <classify classification="BULK" trafficclass="besteffort"/> Java declarations: public class QosFlowAction extends OutputAction { protected Map<String,QoSClass> classMappings; // Other fields here public QosFlowAction() { classMappings = new HashMap<String,QoSClass>(); } public Map<String, QoSClass> getClassMappings() { return classMappings; } public void setClassMappings(Map<String, QoSClass> classMappings) { this.classMappings = classMappings; } // other methods here } public abstract class QoSNode implements Scriptable { // other fields here protected String name;public QoSNode() {children = new LinkedList<QoSNode>(); parameters = new HashMap<String,String>(); } // other stuff here public String getName() { return name; } public void setName(String name) { this.name = name; } } public class QoSClass extends QoSNode { // no other useful stuff in here } --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email
-- Syscon Ingenieurbüro für Meß- und Datentechnik GmbH Ralf Joachim Raiffeisenstraße 11 72127 Kusterdingen Germany Tel. +49 7071 3690 52 Mobil: +49 173 9630135 Fax +49 7071 3690 98 Internet: www.syscon.eu E-Mail: [EMAIL PROTECTED] Sitz der Gesellschaft: D-72127 Kusterdingen Registereintrag: Amtsgericht Stuttgart, HRB 382295 Geschäftsleitung: Jens Joachim, Ralf Joachim --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

