RE: [xsl] WhiteSpace

Subject: RE: [xsl] WhiteSpace
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 6 Nov 2003 15:14:15 -0000
> 
> When I apply the below template to my xml I get &#xA; in 
> place of white space.  How do can I remove the &#xA;?  I 
> thought <xsl:strip-space> would romove the hard spaces in the xml.

xsl:strip-space is about removing white-space-only text nodes.

If you want to replace newline characters by space characters, use the
normalize-space() function.

Newlines in attribute values are always serialized as &#xa; to ensure
that they survive the round trip through serialization and parsing.

Michael Kay

> 
> 
> ###########Template Used##########
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
> <xsl:output method="xml" version="1.0" encoding="UTF-8" 
> indent="yes"/> <xsl:strip-space elements="*"/>
>  
> 
> <xsl:template match="/ | node() | @* | comment() | 
> processing-instruction()">
>   <xsl:copy>
>     <xsl:apply-templates select="@* | node()"/>
>   </xsl:copy>
> </xsl:template>
>    
> </xsl:stylesheet>
> 
> ########### XML #################
> <?xml version="1.0" encoding="UTF-8"?>
> <BODY>
> 		<P style="font-size:12.0">
> 			<SPAN style="font-family:'Times New 
> Roman','Times
> New Roman',Serif;
>  font-size:12.0pt;
>  font-style:normal;
>  font-weight:bold;
>  font-stretch:normal;
>  font-variant:normal;
>  color:#000000">CHAPTER 2 </SPAN>
> 		</P>
> 	<P style="font-size:12.0">
> 			<SPAN style="font-family:'Times New 
> Roman','Times
> New Roman',Serif;
>  font-size:12.0pt;
>  font-style:normal;
>  font-weight:bold;
>  font-stretch:normal;
>  font-variant:normal;
>  color:#000000">TITLE </SPAN>
> 		</P>
> </BODY>
> 
> 
> ############# OUTPUT ################
> 
> <BODY>
> 	<P style="font-size:12.0">
> 		<SPAN style="font-family:'Times New 
> Roman','Times New Roman',Serif;&#xA; font-size:12.0pt;&#xA; 
> font-style:normal;&#xA; font-weight:bold;&#xA; 
> font-stretch:normal;&#xA; font-variant:normal;&#xA; 
> color:#000000">CHAPTER 2 </SPAN>
> 	</P>
> 	<H1 style="font-size:12.0">
> 		<SPAN style="font-family:'Times New 
> Roman','Times New Roman',Serif;&#xA; font-size:12.0pt;&#xA; 
> font-style:normal;&#xA; font-weight:bold;&#xA; 
> font-stretch:normal;&#xA; font-variant:normal;&#xA; 
> color:#000000">TITLE </SPAN> </BODY>
> 
>  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