xsl-list
[Top] [All Lists]

RE: WhiteSpace

2003-11-06 08:14:15

When I apply the below template to my xml I get 
 in 
place of white space.  How do can I remove the 
?  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



<Prev in Thread] Current Thread [Next in Thread>
  • WhiteSpace, Jason Clark
    • RE: WhiteSpace, Michael Kay <=