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

RE: question on apply-templates and strip-space

Subject: RE: question on apply-templates and strip-space
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Thu, 21 Feb 2002 09:36:12 -0000
libxslt removes spaces
<xsl:strip-space> only removes text nodes that consist entirely of white
space. To remove white-space that's part of the same text node as printable
characters, use the normalize-space() function.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Alice Tull
> Sent: 21 February 2002 00:55
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  question on apply-templates and strip-space
>
>
>
> Hi,
>
> I'm new to XSL. I'm trying to get the following input:
>
> 	<MyStuff>
> 	     <Tag1>
> 		This is just a <Tag2>normal</Tag2> line.
> 	     </Tag1>
> 	     <Tag1>
> 		This is the second <Tag2>normal</Tag2> line.
> 	     </Tag1>
> 	</MyStuff>
>
> To be generated as the following output:
>
> 	Ta-Da:This is just a {1} line.
> 	Ta-Da:This is the second {1} line.
>
> I want the result to be simple "text" rather than XML or HTML.
>
> Here's my stylesheet:
>
> 	<xsl:stylesheet version="1.0"
> 	 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
> 	   <xsl:output method="text" indent="no" />
>
> 	   <xsl:strip-space elements="*"/>
>
> 	   <xsl:template match="Tag2">{<xsl:number
> count="*"/>}</xsl:template>
>
> 	   <xsl:template match="/">
> 	    <xsl:for-each select="MyStuff">
> 	      <xsl:text>Ta-Da:</xsl:text>
> 	      <xsl:apply-templates
> select="Tag1"/><xsl:text>&#xA;</xsl:text>
> 	    </xsl:for-each>
> 	   </xsl:template>
> 	</xsl:stylesheet>
>
> My output was:
> 	Ta-Da:
> 	   This is just a {1} line.
>
> 	Ta-Da:
> 	   This is the second {1} line.
>
> Which has more spaces and linefeeds than I want.
> The spaces in the text output was exactly the same as the spaces in
> the original xml file. Shouldn't "strip-space" get rid of the
> linefeed and spaces in the original <Tag1> node? Will normalize-space
> help, and how to use it in the case where I need to apply-templates?
>
> Btw, I tried this on the latest version on both Xalan and libxslt.
>
> thanx,
> alice
>
>
>
>  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.