XSL ignores my whitespace even with the <xsl:text> tag XSL ignores my whitespace even with the <xsl:text> tag xml xml

XSL ignores my whitespace even with the <xsl:text> tag


You may need the to use...

<xsl:text xml:space="preserve">    Gender: Male    </xsl:text>


If you want to output a text file you should specify an <xsl:output method="text"/> as a child of the <xsl:stylesheet> element.

When treating output as HTML the parser might pack your spaces, if HTML output with non-breaking spaces is what you want you can use the &#160; non-breaking space entity (note that   might not work since it's not an XML entity, unless you declare it yourself).


This not a strict XSLT question, as XSLT does not eat your white space. This transformation

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">  <xsl:template match="/">    <foo>      <xsl:text>    Gender: Male    </xsl:text>    </foo>  </xsl:template></xsl:stylesheet> 

gives

<?xml version="1.0" encoding="UTF-8"?><foo>    Gender: Male    </foo>

You are using HTML as the output? Then use non breaking space for whitespace.