I'm making a header in my XSL code that includes multiple fields of information, i.e. "Name: Bob Birthdate: January 1 1900," etc. I enclosed them in tags as such:
<xsl:text> Gender: Male </xsl:text>
But on the page, the whitespace around Gender/Male is being ignored. Is there something I'm missing?
Thanks in advance.
You need to add
instead of spaces. To get more than 1 space<xsl:text><![CDATA[ Gender: Male ]]></xsl:text>
This not a strict XSLT question, as XSLT does not eat your white space. This transformation
gives
You are using HTML as the output? Then use non breaking space for whitespace.
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
 
non-breaking space entity (note that
might not work since it's not an XML entity, unless you declare it yourself).You may need the to use...
Just use
it represent whitespace in xsl like
in html