HOME  |    TRAINING  |   FREE TUTORIALS   |   JOBS
Find out more about our new RSS feed.
FREE Tutorial
PROFESSIONAL ASP XML : CASE STUDY DATA DRIVEN XSL PART 2 - THE DATA

CATEGORY
SEARCH OUR OTHER TUTORIALS

DESCRIPTION

This case-study uses three XML files:
- The incoming data (input, aka: "incoming.xml")
- The translation definition file (process, aka: "interpreter.xml")
- The translated data (output, seen from the test page)


This free tutorial is a sample from the book Professional ASP XML.


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:

  • "carrier" becomes "shippedby"
  • "shipDate" becomes "shipped"
  • "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.




5 RELATED COURSES AVAILABLE
HTML 4.0 INTRODUCTION
To create, format and publish a small website using HTML 4.0. You will learn to create web pages incorporating fo....
MICROSOFT INTERNET EXPLORER 6.0 INTERNET INTRODUCTION
This course provides readers with an introduction to the concept of the Internet and the opportunity to gain a br....
A+ MODULE 5 - THE INTERNET
At the end of this course you will be able to: describe the functions of an operating system, describe the featur....
JAVASCRIPT PROGRAMMING
This training course aims to teach the reader the fundamentals of JavaScript. This course covers topics such as -....
I-NET+ MODULE 8 - DEVELOPING A WEB SITE
On completion of this module, readers will be able to: create HTML pages incorporating different document-, parag....
 
0 RELATED JOBS AVAILABLE
CONTACT US
Sunday 7th September 2008  © COPYRIGHT 2008 - VISUALSOFT