spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / resources / books

Back Contents Next

The Data

This case-study uses three XML files:

 

q         The incoming data (input, aka: "incoming.xml")

q         The translation definition file (process, aka: "interpreter.xml")

q         The translated data (output, seen from the test page)

 

Let's look at the structure of each of these:

Input XML

<?xml version='1.0'?>

<shipments>

   <shipment>

      <waybill>123WXZ99</waybill>

      <carrier>Fedex</carrier>

      <shipDate>20000110</shipDate>

      <boxes>3</boxes>

   </shipment>

   <shipment>

      <waybill>79843A</waybill>

      <carrier>UPS</carrier>

      <shipDate>20000110</shipDate>

      <boxes>2</boxes>

   </shipment>

   <shipment>

      <waybill>XXX12A</waybill>

      <carrier>Fedex</carrier>

      <shipDate>20000110</shipDate>

      <boxes>8</boxes>

   </shipment>

</shipments>

Output XML

<?xml version='1.0'?>

<shipments>

   <shipment>

      <waybill>123WXZ99</waybill>

      <shippedby>Fedex</shippedby>

      <shipped>20000110</shipped>

      <numberOfBoxes>3</numberOfBoxes>

   </shipment>

   <shipment>

      <waybill>79843A</waybill>

      <shippedby>UPS</shippedby>

      <shipped>20000110</shipped>

      <numberOfBoxes>2</numberOfBoxes>

   </shipment>

   <shipment>

      <waybill>XXX12A</waybill>

      <shippedby>Fedex</shippedby>

      <shipped>20000110</shipped>

      <numberOfBoxes>8</numberOfBoxes>

   </shipment>

</shipments>

The Translation Process

As you can see, the input and desired output files have a similar structure, but there are three differences:

 

q         "carrier" becomes "shippedby"

q         "shipDate" becomes "shipped"

q         "boxes" becomes "numberOfBoxes"

 

The required element mapping is defined in the following XML file:

 

 

 

 

 

 

 

 

 

<?xml version='1.0'?>

<shipments>

   <shipment>

      <xlat>

         <in name="waybill"/>

         <out name="waybill"/>

      </xlat>

      <xlat>

         <in name="carrier"/>

         <out name="shippedby"/>

      </xlat>

      <xlat>

         <in name="shipDate"/>

         <out name="shipped"/>

      </xlat>

      <xlat>

         <in name="boxes"/>

         <out name="numberOfBoxes"/>

      </xlat>

   </shipment>

</shipments>

 

As you can see, each <xlat> element contains an input element name and an output element name. This is the mapping we will use when we build our XSL. Note that the first of the <xlat> elements does something rather pointless – replacing "waybill" with "waybill". This has been included just to keep the code as simple as possible. You could put in some code to tell the interpreter not to process the <waybill> tags and only change the others.

We could easily create similar translation documents for any number of input documents. This would allow us to translate all input documents with the same ASP page.

 


BackContentsNext
©1999 Wrox Press Limited, US and UK.

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business


Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/resources/books/professionalaspxml/40281002.htm
Created: Jan. 05, 2001
Revised: Jan. 05, 2001