Hi! I'm trying to unmarshall this input

<root>
    <children key="key1">value1</children>
    <children key="key2">value2</children>
    <children key="key3"></children>
</root>

using this mapping

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
   <mapping>
     <class name="Root">
         <map-to xml="root"/>
         <field name="children" collection="map">
             <bind-xml name="children">
                 <class name="org.exolab.castor.mapping.MapItem">
                     <field name="key" type="string">
                         <bind-xml name="key" node="attribute"/>
                     </field>
                     <field name="value" type="string">
                         <bind-xml node="text"/>
                     </field>
                 </class>
             </bind-xml>
         </field>
     </class>
   </mapping>

and this code

      Mapping map = new Mapping();
      map.loadMapping("mapping.xml");
      Unmarshaller un = new Unmarshaller(Root.class);
      un.setMapping(map);
      Root root = (Root) un.unmarshal(new FileReader("input.xml"));

then this exception is thrown because of the empty node "key3" (I suppose)

Caused by: ValidationException: unable to resolve reference:
org.exolab.castor.mapping.MapItem@7f8062
        at 
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:907)
        at 
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1119)
        at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown 
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:729)
        at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:621)

is there any way to unmarshall this?
Thank you

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to