[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: Charlotte Allen <Charlotte.Allen@xxxxxxxxxxxx>
Date: Thu, 19 Aug 1999 16:19:19 -0700 (PDT)
xml ascii
Mitch,

Basically, you want something like this:

xsl:
----------------------------------------
<!DOCTYPE xsl:stylesheet SYSTEM "xsl-html.dtd">

<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"
                xmlns="http://www.w3.org/TR/REC-html40">

<xsl:output method="text" indent="no"/>

<!-- Root template - start processing here -->
<xsl:template match="/">
<xsl:text>firstname     lastname        phone</xsl:text>
<xsl:apply-templates select="./*"/>
</xsl:template>

<xsl:template match="order">
<xsl:value-of select="./customer/firstname/text()"/>
<xsl:text>      </xsl:text>
<xsl:value-of select="./customer/lastname/text()"/>
<xsl:text>              </xsl:text>
<xsl:value-of select="./customer/phone/text()"/>
</xsl:template>

</xsl:stylesheet>
-------------------------------------------------------------------

which will generate this ascii from your xml:
-------------------------------------------------------------------
firstname       lastname        phone
    John        Doe             (510) 555-1212
    Jane        Smith           (916) 555-1212
-------------------------------------------------------------------

Note that my XSL processor (LotusXSL v0.17.0) seems to be ignoring 
my indent="no" instruction and is adding white space before the
first names. Anyone know why this might be? Or is there something
else I missed?

Hopefully your XSL processor will not do this.

Hope this is helpful.

Charlotte Allen

> Date: Thu, 19 Aug 1999 14:37:28 -0700
> From: Mitch Christensen <mitch_christensen@xxxxxxxxx>
> X-Accept-Language: en
> MIME-Version: 1.0
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Re: XML->ascii Conversion
> 
> Hi Mike,
> 
> Thanks for responding.  I'll try to be both specific and consise.
> 
> 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
> 
> My current model is as follows...
> 
>    qbout.xml-      +-----------+
>               \    |           |
>                +-->+ ixslt.exe +---> outfile.txt
>               /    |           |
> qb2ascii.xsl-      +-----------+
> 
> I just can't seem to get this to work.
> 
> If you have an example or any advice at all, I would greatly appreciate it.
> 
> Thanks,
> Mitch
> 
> 
> Mike Brown wrote:
> 
> > > I need to convert XML to straight ascii text.
> >
> > Are you wanting to convert an XML document from one character set encoding
> > like UTF-8 to US-ASCII, so the document is the same, i.e. markup and data,
> > just with some of the characters changed to something suitable for your
> > display ... or are you wanting to emit, for example, just the names of
> > elements and their contents, perhaps like myElement: 'someValue', or what?
> > Be more specific, showing what you have as input and what you want as
> > output.
> >
> >  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 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.