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

Re: White space control when formatting for ascii text

Subject: Re: White space control when formatting for ascii text
From: Dan Vint <dvint@xxxxxxxx>
Date: Tue, 17 Oct 2000 13:37:13 -0700 (PDT)
xsl ascii tab
Quick guess as you have covered the usual problem with spaces in the template
by surrounding your live text with <xsl:text elements is that some problems
may be generated by the white space in your source data.

Use something like this to strip the text output:

<xsl:template match="text()">
	<xsl:value-of select="normalize-space(.)"/>
</xsl:template>

that should get rid of any extra spaces, CR's and tabs that would come
from the formatting in the source data.

..dan


> 
> I'm attempting to transform some xml into nicely formatted ascii style
> text instead of to html.  I've been using tabs to align my columns but
> sometimes I get extra tabs. I don't know why.
> 
> It seems to be very difficult to control the white space in the style
> sheet.  Is there a way to make the white space more visibile for better
> debugging? 
> 
> I switched to using the unicode characters for return and tab.  
> return = &#xA; and tab = &#9; so that I could know what tabs and line
> breaks I was putting in.
> 
> Maybe I've missed something.
> 
> Style sheet output:
> -------------------
> 
> <?xml version="1.0" encoding="utf-8"?>
> This is a listing of fields by category
> 
> Category:  People
> 
> PersonID        Global unique identifier for a person.
>       SSN       Social Security Number
>       Firstname First Name
>       Lastname  Last Name
>       Middlename        Middle Name
>       DOB       Date of birth
>       Gender    Gender of the person.
> ^
> |--------no reason for tab here.
> 
> Style sheet:
> ------------
> <xsl:stylesheet version="1.0"
>                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:strip-space elements="*"/>
> 
> <xsl:template match="fieldlist">
> <xsl:text>This is a listing of fields by category&#xA;</xsl:text>
> <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="table">
> <xsl:text>&#xA;</xsl:text>
> <xsl:text>Category:  </xsl:text>
> <xsl:apply-templates/>
> </xsl:template>
> 
> <xsl:template match="name">
> <xsl:apply-templates/>
> <xsl:text>&#xA;&#xA;</xsl:text>
> </xsl:template>
> 
> <xsl:template match="field">
> <xsl:value-of select="@name"/>
> <xsl:text>&#9;</xsl:text>
> <xsl:apply-templates/>
> </xsl:template>
> 
> 
> <xsl:template match="desc">
> <xsl:apply-templates/>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> Original xml:
> -------------
> <?xml version="1.0" standalone="no"?>
> <!DOCTYPE fieldlist SYSTEM "fieldlist.dtd">
> <fieldlist>
>   <table>
>     <name>People</name>
> 
>     <field name="PersonID" type="Number(10)" keytype="PRIMARY KEY">
>       <desc>Global unique identifier for a person.
>       </desc>
>     </field>
> 
>     <field name="SSN" type="varchar2(9)" keytype="NOT NULL">
>       <desc>Social Security Number
>       </desc>
>     </field>
> 
>     <field name="Firstname" type="varchar2(20)" keytype="">
>       <desc>First Name
>       </desc>
>     </field>
> 
>     <field name="Lastname" type="varchar2(20)" keytype="">
>       <desc>Last Name
>       </desc>
>     </field>
> 
>     <field name="Middlename" type="varchar2(20)" keytype="">
>       <desc>Middle Name
>       </desc>
>     </field>
> 
>     <field name="DOB" type="Date" keytype="">
>       <desc>Date of birth
>       </desc>
>     </field>
> 
>     <field name="Gender" type="char(1)" keytype="">
>       <desc>Gender of the person.
>       </desc>
>     </field>
>   </table>
> </fieldlist>
> 
> ______________________________________________________
> Rick Anderson	| rianders@xxxxxxxxxxxxxxx
> ________________|_____________________________________
> Continuous Education & Outreach
> Manager of Computer Systems,  (732)932-5071
> ______________________________________________________
> 
> 
> 
>  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.