Hi Ian,

So you want the country information to be represented in the base class, 
while the airport codes are represented in the extension class, right? 
You should be able to do this using a binding of this form:

  <structure name="DepartureAirport" value-style="attribute">
    <value field="originCountryCode" name="CountryCode"/>
    <value field="depAirPortCode" name="LocationCode"/>
  </structure>
  <structure name="ArrivalAirport" value-style="attribute">
    <value field="destinationCountryCode" name="CountryCode"/>
    <value field="arrAirPortCode" name="LocationCode"/>
  </structure>

(assuming the fields in the Leg class are public or protected; otherwise 
you can wrap a <structure type="com.ian.Leg"> around each of the 
<values> from the base class).

So rather than defining a separate <mapping> for the base class, you 
just embed it into the extension class. That's not the best 
representation from the code point of view, but since the code structure 
is different from the XML structure you need to adapt to the difference 
in the binding.

  - Dennis

Dennis M. Sosnoski
XML and Web Services in Java
Training and Consulting
http://www.sosnoski.com - http://www.sosnoski.co.nz
Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117



ian beer wrote:
> Hi i am trying to map an OTA_AirBookRQ into a java structure. My 
> Structure consists of a class called Leg with two attributes origin 
> country code and destination country code. Class Flight extends Leg.
>
> The data lives in this section of the xml
>
> <ns3:FlightSegment ArrivalDateTime="2009-03-16T10:45:00.000Z" 
> DepartureDateTime="2009-03-16T07:10:00.000Z" E_TicketEligibility="Y" 
> FlightNumber="2722" FlightType="SH" ResBookDesigCode="O">
>     <ns3:DepartureAirport CountryCode="GB" LocationCode="LGW" 
> Terminal="N"/>
>     <ns3:ArrivalAirport CountryCode="GB" LocationCode="ALC" Terminal=""/>
>     <ns3:OperatingAirline Code="BA" CompanyShortName="British Airways"/>
>     <ns3:MarketingAirline Code="BA" CompanyShortName="British Airways"/>
> </ns3:FlightSegment>
>
> Ok so its the CountryCode attribute in Departure / arrival airport i 
> am after here.
>
> So how do i get the <structure map-as="Leg"/> to conform to an attribute?
>
> Everytime i run the unmarshaller it falls over with this
>
> org.jibx.runtime.JiBXException: Expected "DepartureAirport" start tag, 
> found "{http://www.opentravel.org/OTA/2003/05}DepartureAirport"; end 
> tag (line 10, col 74)
>     at 
> org.jibx.runtime.impl.UnmarshallingContext.matchStart(UnmarshallingContext.java:652)
>     at 
> org.jibx.runtime.impl.UnmarshallingContext.parseToStartTag(UnmarshallingContext.java:670)
>     at com.ian.Leg.JiBX_AirBookBinding_unmarshal_1_0(Leg.java)
>     at com.ian.Flight.JiBX_AirBookBinding_unmarshal_2_1(Flight.java)
>     at com.ian.JiBX_AirBookBindingFlight_access.unmarshal()
>     at 
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalElement(UnmarshallingContext.java:2762)
>     at 
> org.jibx.runtime.impl.UnmarshallingContext.unmarshalDocument(UnmarshallingContext.java:2905)
>     at com.ian.Harness.main(Harness.java:20)
>
>
> This is the binding file, which is clearly wrong
>
> <binding>
> <mapping class="com.ian.Leg" abstract="true">
>         <structure name="DepartureAirport" value-style="attribute">
>             <value name="CountryCode" field="originCountryCode"/>
>         </structure>
>         <structure name="ArrivalAirport" value-style="attribute">
>             <value name="CountryCode" field="destinationCountryCode"/>
>         </structure>
> </mapping>
>
> <mapping name="OTA_AirBookRQ" class="com.ian.Flight" 
> extends="com.ian.Leg">
>     <namespace uri="http://www.opentravel.org/OTA/2003/05"; 
> default="elements"/>
>    
>     <value name="TransactionIdentifier" style="attribute" 
> field="transCode"/>
>     <structure name="FlightSegment" value-style="attribute">
>         <value name="FlightNumber" field="flightNo"/>
>         <value name="E_TicketEligibility" field="eTicketEligible"/>
>         <value name="FlightType" field="flightType"/>
>         <value name="FlightNumber" field="flightNo"/>
>        
>         <structure name="DepartureAirport" value-style="attribute">
>             <value name="LocationCode" field="depAirPortCode"/>
>             <structure map-as="com.ian.Leg"/>
>         </structure>
>        
>         <structure name="ArrivalAirport" value-style="attribute">
>             <value name="LocationCode" field="arrAirportCode"/>
>         </structure>
>        
>         <structure name="OperatingAirline" value-style="attribute">
>             <value name="Code" field="carrierCode"/>
>             <value name="CompanyShortName" field="carrierName"/>
>         </structure>
>        
>         <structure name="MarketingAirline"/>
>     </structure>
>    
>    
> </mapping>
> </binding>
>
>
> Can anyone please help this is urgent.
>
> Thanks in advance
> ------------------------------------------------------------------------
> View your other email accounts from your Hotmail inbox. Add them now. 
> <http://clk.atdmt.com/UKM/go/167688463/direct/01/>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
> trial. Simplify your report design, integration and deployment - and focus on 
> what you do best, core application coding. Discover what's new with 
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> jibx-users mailing list
> jibx-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jibx-users
>   

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to