[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XML->ascii Conversion

Subject: RE: XML->ascii Conversion
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Thu, 19 Aug 1999 17:14:19 -0600
ascii x9
> I want to translate the following... 
> 
> <orderlist> 
>     <order ordernum="1"> 
>         <customer> 
>             <firstname>John</firstname> 
>             <lastname>Doe</lastname> 
>             <phone>(510) 555-1212</phone> 
>         </customer 
>     </order> 
>     <order ordernum="2"> 
>         <customer> 
>             <firstname>Jane</firstname> 
>             <lastname>Smith</lastname> 
>             <phone>(916) 555-1212</phone> 
>         </customer 
>     </order> 
> </orderlist> 
> 
> into a tab-delimited ascii file for import into QuickBooks like this... 
> 
> firstname    lastname    phone 
> John         Doe         (510) 555-1212 
> Jane         Smith       (916) 555-1212

Here you go, with some comments to explain:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0">
 <!-- if using an implementation of the current XSLT WD -->
 <xsl:output method="text"/>
 <!-- execute this template if the element name is 'orderlist' -->
 <xsl:template match="orderlist">
  <!-- emit column headers with tabs and a newline -->
  <xsl:text>firstname&#x9;lastname&#x9;phone&#xA;</xsl:text>
  <!-- process elements named 'customer' that are children of
       elements named 'order' that are children of the current
       node -->
  <xsl:for-each select="order/customer">
   <!-- select as a node-set the elements named 'firstname'
        that are children of the current node, and emit the
        concatenation of text nodes contained within the
        first node in that node-set -->
   <xsl:value-of select="firstname"/>
   <xsl:text>&#x9;</xsl:text>
   <xsl:value-of select="lastname"/>
   <xsl:text>&#x9;</xsl:text>
   <xsl:value-of select="phone"/>
   <xsl:text>&#xA;</xsl:text>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>

  


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.