title: Castor XML Mapping same name with the child node
body: <p>I am facing a problem with castor while trying to parse an xml which contains same name for the parent and child node... Here are the details:</p>
  
  <p>This is the part of the mapping file:</p>
  
  <pre><code>&lt;class name="com.somepackage.Item"&gt;
      &lt;field name="id" type="java.lang.long"&gt;
        &lt;bind-xml name="itemiD" node="element"/&gt;
      &lt;/field&gt;
      &lt;field name="amount" type="com.somepackage.Amount"&gt;
        &lt;bind-xml name="amount" /&gt;
      &lt;/field&gt;
  &lt;/class&gt;
  &lt;class name="com.somepackage.Amount" &gt;
    &lt;field name="amount" type="java.lang.String"&gt;
      &lt;bind-xml name="amount" /&gt;
    &lt;/field&gt;
    &lt;field name="currency" type="java.lang.String"&gt;
      &lt;bind-xml name="currency" /&gt;
    &lt;/field&gt;
  &lt;/class&gt;
  </code></pre>
  
  <p>And this is the xml which I am trying to parse:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;list xmlns="http://someurl"&gt;
  &lt;item&gt;
  &lt;itemID&gt;42425&lt;/itemID&gt;
  &lt;amount&gt;
    &lt;amount&gt;10.00&lt;/amount&gt;
    &lt;currency&gt;EUR&lt;/currency&gt;
  &lt;/amount&gt;
  &lt;item&gt;
  &lt;/list&gt;
  </code></pre>
  
  <p>And this is the error logs related with the above stuff:</p>
  
  <pre>
  
  [#|2013-11-20T13:48:54.670+0800|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=32;_ThreadName=Thread-2;|13-11-20 13:48:54 ERROR util.XMLConvertUtil http-thread-pool-8181(1) - org.exolab.castor.xml.MarshalException: Illegal Text data found as child of: amount
    value: "10.00"{File: [not available]; line: 14; column: 29}
  org.exolab.castor.xml.MarshalException: Illegal Text data found as child of: amount
    value: "10.00"{File: [not available]; line: 14; column: 29}
    at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:727)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
    at some.package.XMLConvertUtil.xmlToObject(XMLConvertUtil.java:58)
    at some.package.ConverUtil.xmlToPojo(ConverUtil.java:31)
    at some.package.XMLParser.process(XMLParser.java:89)
    at some.package.XMLParser.doPost(XMLParser.java:1063)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
  Caused by: org.xml.sax.SAXException: Illegal Text data found as child of: amount
    value: "10.00"
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:874)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1159)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:715)
    ... 31 more
  Caused by: org.xml.sax.SAXException: Illegal Text data found as child of: amount
    value: "10.00"
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:874)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1159)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:715)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
    at some.package.XMLConvertUtil.xmlToObject(XMLConvertUtil.java:58)
    at some.package.ConverUtil.xmlToPojo(ConverUtil.java:31)
    at some.package.XMLParser.process(XMLParser.java:89)
    at some.package.XMLParser.doPost(XMLParser.java:1063)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:688)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)
    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)
    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
    at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)
    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)
    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)
    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)
    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)
    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)
    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
    at com.sun.gr|#]
  
  [#|2013-11-20T13:48:54.671+0800|INFO|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=32;_ThreadName=Thread-2;|izzly.ContextTask.run(ContextTask.java:71)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
    at java.lang.Thread.run(Thread.java:662)
  |#]
  
  </pre>
  
  <p>Is it a bug or some other problem that I need to change something in the mapping? There is no way to change the xml and its schema as I am getting it from a third party. if there is no way to handle this changing the mapping and so on, shall i use another parser? </p>