Hi,

 

I am using castor mapping file for binding xml with java objects.

 

My business requirement is:

I need to map Xml element to any field of java object.

For that I have used location attribute in bind-xml of mapping file.

But for the very first bind it will map element with java object and
castor will not map for second time.

 

Problem:

Element A1 of YY node, element b1 of AA node has to unmarshall into Bis5
object

And element b1 of YY node, element c1 of AA node has to unmarshall into
Bpi5 object.

 

For example:

 

XML file:

<?xml version="1.0" encoding="UTF-8"?>

<ACORD>

      <InsuranceSvcRq>

            <Pers>

                  <zz>

                        <YY>

                              <a1>testData1</a1>

                              <b1>testData2</b1>

                        </YY>

                  </zz>

                  <AA>

                        <b1>testData3</b1>

                        <c1>testData4</c1>

                  </AA>

            </Pers>

      </InsuranceSvcRq>

</ACORD>

 

Mapping file:

<? xml version="1.0"?>

<! DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Object Mapping DTD Version
1.0//EN" "http://castor.exolab.org/mapping.dtd";>

<mapping>

<description>A mapping file used for unmarshalling and
marshalling</description>

 

<class name="com.SYNCord.AL3.CUSTOM">

      <map-to xml="ACORD" />

      

      <field name="bis5" type="com.SYNCord.AL3.Bis5"
collection="collection">

            <bind-xml name="Pers" location="InsuranceSvcRq" />

      </field>

      

      <field name="bpi5" type="com.SYNCord.AL3.Bpi5"
collection="collection">

            <bind-xml name="Pers" location="InsuranceSvcRq" />

      </field>

      

</class>

 

<class name="com.SYNCord.AL3.Bis5">

      <field name="tag1" type="java.lang.String">

            <bind-xml name="a1" location="zz/YY"/>

      </field>

      <field name="tag2" type="java.lang.String">

            <bind-xml name="b1" location="AA"/>

      </field>

</class>

 

<class name="com.SYNCord.AL3.Bpi5">

      <field name="tag1" type="java.lang.String">

            <bind-xml name="b1" location="zz/YY"/>

      </field>

      <field name="tag2" type="java.lang.String">

            <bind-xml name="c1" location="AA"/>

      </field>

</class>

 

</mapping>

 

Output Xml:

<CUSTOM>

    <bis5>

        <tag2>testData3</tag2>

        <tag1>testData1</tag1>

    </bis5>

</CUSTOM>

 

But according to mapping file actual output file that I am expecting is
as below:

Expected Output Xml:

<?xml version="1.0" encoding="UTF-8"?>

<CUSTOM>

    <bpi5>

        <tag2>testData4</tag2>

        <tag1>testData2</tag1>

    </bpi5>

    <bis5>

        <tag2>testData3</tag2>

        <tag1>testData1</tag1>

    </bis5>

</CUSTOM>

 

My question is what changes I have to make in my Mapping file so that I
will get <bpi5> element (marked as red in expected output Xml)?

 

It will help a lot if any solution will be given to this problem. 

 

Regards,

 

Mustafa Nimakwala

Nortal - 0202 3872, Cell - 9823127867

 


Confidential: This electronic message and all contents contain information from 
Syntel, Inc. which may be privileged, confidential or otherwise protected from 
disclosure. The information is intended to be for the addressee only. If you 
are not the addressee, any disclosure, copy, distribution or use of the 
contents of this message is prohibited. If you have received this electronic 
message in error, please notify the sender immediately and destroy the original 
message and all copies.

Reply via email to