0

I have the following XML which I need to develop a Jibx binding for

<?xml version="1.0" encoding="UTF-8"?>
<conf:confirmationMessage xmlns:conf="http://webaddress/entity/confirmation/v1_0" xmlns:cli="http://webaddress/entity/client/v1_0" xmlns:cust="http://webaddress/entity/custodian/v1_0" xmlns:fin="http://webaddress/entity/financial/v1_0" xmlns:sto="http://webaddress/entity/stock/v1_0" xmlns:tra="http://webaddress/entity/trade/v1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://webaddress/entity/confirmation/v1_0 ../XSD_V2/Confirmation.xsd ">
   <conf:id>20130313588741</conf:id>
   <conf:status>CS Generated</conf:status>
   <conf:type>INS</conf:type>
   <conf:trade>
       <tra:tradeID>3068353</<tra:tradeID>
       <tra:clientID>82911</<tra:clientID>
       <<tra:tradeDate>2013-02-28T00:00:00</<tra:tradeDate>
   </conf:trade>
</conf:confirmationMessage>

I wrote the following biding but its not working because of the namespace "tra"

<?xml version="1.0" encoding="UTF-8"?>
<binding>
    <mapping name="confirmationMessage" class="com.webaddress.Confirmation">
        <namespace uri="http://webaddress/entity/confirmation/v1_0" default="elements"/>
        <value name="id" field="id" default="default-value" usage="optional" />
        <value name="status" field="status" default="default-value" usage="optional" />
        <value name="type" field="type" default="default-value" usage="optional" />
        <collection field="trade" factory="com.package.trades.JibxConfirmationUmarshaller.listFactory">
            <!--<structure map-as="com.webaddress.Trade" />-->
            <structure name="trade" />
        </collection>
    </mapping> 

    <mapping name="trade" class=om.webaddress.Trade">
        <namespace prefix="tra" uri="http://webaddress/entity/trade/v1_0" default="elements"/>
        <value name="tradeID" field="tradeID" default="default-value" usage="optional" />

        <value name="clientID" field="clientID" usage="optional"
        deserializer="com.package.trades.JibxConfirmationUmarshaller.deserializeBigInt" />

        <value name="tradeDate" field="tradeDate" usage="optional"
        deserializer="com.package.trades.JibxConfirmationUmarshaller.deserializeDate" />
        <value name="activity" field="activity" default="default-value" usage="optional" />
    </mapping>
</binding>

Any ideas how i can make this work?

Farouk Alhassan
  • 3,780
  • 9
  • 51
  • 74

1 Answers1

1
The issue probably lies in the fact that the name "trade" is from the namespace
"http://webaddress/entity/confirmation/v1_0".  Your jibx binding makes it assume
that "trade" is from the namespace "http://webaddress/entity/trade/v1_0".

The strings "conf" and "tra" are just abbreviations for
"http://webaddress/entity/confirmation/v1_0" and "http://webaddress/entity/trade/v1_0"

The right answer probably looks something like this:

<mapping name="trade" ns="http://webaddress/entity/confirmation/v1_0"class=om.webaddress.Trade">
    <namespace prefix="tra" uri="http://webaddress/entity/trade/v1_0" default="elements"/>
    <namespace uri="http://webaddress/entity/confirmation/v1_0"/>
    <value name="tradeID" field="tradeID" default="default-value" usage="optional" />

    <value name="clientID" field="clientID" usage="optional"
    deserializer="com.package.trades.JibxConfirmationUmarshaller.deserializeBigInt" />

    <value name="tradeDate" field="tradeDate" usage="optional"
    deserializer="com.package.trades.JibxConfirmationUmarshaller.deserializeDate" />
    <value name="activity" field="activity" default="default-value" usage="optional" />
</mapping>

You need the tag containing any namespace that you plan to use, but then you need to add the "ns=" to any element that uses that namespace (unless the "default=" clause applies). In this case, you do not want to use the default namespace for the "trade" element. You want to use the other namespace.

The prefix= is only needed if you plan to use this binding for output.