[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: Mike Brown <mike@xxxxxxxx>
Date: Tue, 17 Oct 2000 15:29:41 -0600 (MDT)
ascii white space
Rick Anderson wrote:
> sometimes I get extra tabs. I don't know why.

> Is there a way to make the white space more visibile for better
> debugging? 

<xsl:template match="text()">
  <xsl:value-of select="translate(.,'&#9;&#10;','&#x2192;&#x2193;')"/>
</xsl:template>

(affects text nodes reached via xsl:apply-templates, not the ones you
create with xsl:text)

Although this explanation might help even more...

     <field name="SSN" type="varchar2(9)" keytype="NOT NULL">
       <desc>Social Security Number
       </desc>
     </field>

When you do stuff like this, note that the whitespace that is adjacent to
the non-whitespace text is considered part of the same text node. This
whitespace is not in a node by itself. If it were, then your
xsl:strip-space would get rid of it. Before the strip-space takes effect,
you have the following nodes (I'll use \t and \n to represent tabs for
indenting and newline characters, respectively):

|__text '\t'
|__element 'field' in no namespace
     |  \attribute 'name'='SSN'
     |  \attribute 'type'='varchar2(9)'
     |  \attribute 'keytype'='NOT NULL'
     |  \namespace prefix 'xml'='http://www.w3.org/XML/1998/namespace'
     |__text '\n\t\t'
     |__element 'desc' in no namespace
     |    |  \namespace prefix 'xml'='http://www.w3.org/XML/1998/namespace'
     |    |__text 'Social Security Number\n\t\t'
     |__text '\n\t'

xsl:strip-space will get rid of just the text nodes that contain
whitespace only.

If you can't get the whitespace out of your other text nodes by adjusting
the original XML, try using the normalize-space() function, which will
chop off leading and trailing whitespace and condense consecutive
whitespace characters down to a single space character.

   - Mike
____________________________________________________________________
Mike J. Brown, software engineer at         My XML/XSL resources:
webb.net in Denver, Colorado, USA           http://www.skew.org/xml/


 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.