[castor.user] nested same name elements

  • From: Vaibhav Agrawal <Vaibhav.Agrawal@xxxxxxxxxxxxxxxxxxxxxx>
  • To: "'castor.user@xxxxxxxxxxxxx'" <castor.user@xxxxxxxxxxxxx>
  • Date: Tue, 6 Oct 2015 04:35:11 +0000

Hi all,

I have a xml with nested elements which I can convert to Java Object using the
location attribute. But, in one of the xml there is a same name nested elements
which are not being converted.

<SettlementNew>
<SecurityCode>
<SecurityCode>AD345989</SecurityCode>
<SecurityCodeType>ISIN</SecurityCodeType>
</SecurityCode>
</SettlementNew>

With mapping file:
<class name="com.vaibhav.MySettlementNew">
<map-to xml="SettlementNew" />
<field name="securityCode" type="string">
<bind-xml name="SecurityCode" node="element"
location="SecurityCode"/>
</field>

<field name="securityCodeType" type="string">
<bind-xml name="SecurityCodeType" node="element"
location="SecurityCode"/>
</field>
</class>

I am using Spring OXM and getting the following exception (SettlementNew is the
root element):

Caused by: org.xml.sax.SAXException: Unable to find FieldDescriptor for
'SecurityCode' in ClassDescriptor of SettlementNew.
at
org.exolab.castor.xml.StartElementProcessor.compute(StartElementProcessor.java:420)
at
org.exolab.castor.xml.UnmarshalHandler.startElementProcessing(UnmarshalHandler.java:841)
at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:766)
at
org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(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.springframework.oxm.castor.CastorMarshaller.unmarshalSaxReader(CastorMarshaller.java:622)

Is there a work around?

Thanks

Vaibhav Agrawal | Analyst Programmer
ABN AMRO | ABN AMRO Clearing Sydney Pty Ltd
Level 8, 50 Bridge Street | Sydney NSW 2000 | Australia
Tel: +61 (0)28221 3031 | Internet abnamroclearing.com
Save a tree! Print this message only if it's absolutely necessary

********
This message (including any attachments ) is confidential and is intended
solely for the use of the individual or entity to whom it is addressed. If you
have received this message by mistake please notify the sender by return email
and delete this message from your system. Any unauthorised use or dissemination
of this message in whole or in part is strictly prohibited.
********

Other related posts: