castor
  1. castor
  2. CASTOR-1025

Elements with the same name (but different location) make Unmarshaller fail

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 0.9.6
    • Fix Version/s: None
    • Component/s: XML
    • Labels:
      None
    • Environment:
      Operating System: MacOS X
      Platform: Macintosh
    • Bugzilla Id:
      1888
    • Number of attachments :
      0

      Description

      Here is an example mapping document fragment:

      <class name="AnyClass">
      <map-to xml="test">
      <field name="urlOne" type="java.lang.String">
      <bind-xml name="url" />
      </field>

      <field name="urlTwo" type="java.lang.String">
      <bind-xml name="url" location="two"/>
      </field>
      </class>

      and a sample input file:

      <test>
      <url>first URL</url>
      <two>
      <url>second URL</url>
      </two>
      </test>

      This causes:

      unable to add 'url' to <test> due to the following exception:
      >>>--- Begin Exception ---<<<
      java.lang.IllegalArgumentException: Type conversion error: could not set value of
      docUrl(java.lang.String) with value of type java.lang.String
      at org.exolab.castor.mapping.loader.FieldHandlerImpl.setValue(FieldHandlerImpl.java:499)
      at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1016)
      at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1084)
      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(Unk
      nown 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:657)
      at com.dcxms.gmsmodel.CastorTest.main(CastorTest.java:32)
      >>>---- End Exception ----<<<

      {file: [not available]; line: 11; column: 78}

      Note that I can play with different XML/mapping file combinations:

      <test>
      <one>
      <url>...</url>
      </one>
      <two>
      <url>...</url>
      </two>
      </test>

      This fails too.

      Same problem exists in 0.9.5.4.

        Activity

        Hide
        Keith Visco added a comment -

        Thanks for the report Peter. I'll set this for 0.9.7 as an indication the it
        should be made available in a bug fix release.

        Show
        Keith Visco added a comment - Thanks for the report Peter. I'll set this for 0.9.7 as an indication the it should be made available in a bug fix release.
        Hide
        Daniel Dyer added a comment -

        This is the same as issue 606 (http://jira.codehaus.org/browse/CASTOR-606), and is causing problems for me too.

        Show
        Daniel Dyer added a comment - This is the same as issue 606 ( http://jira.codehaus.org/browse/CASTOR-606 ), and is causing problems for me too.

          People

          • Assignee:
            Unassigned
            Reporter:
            Peter Wyngaard
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: