Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 676
danielle Avatar asked Apr 27 '10 19:04

danielle


2 Answers

You may need the to use...

<xsl:text xml:space="preserve">    Gender: Male    </xsl:text>
like image 66
dacracot Avatar answered Oct 26 '22 23:10

dacracot


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 &nbsp; might not work since it's not an XML entity, unless you declare it yourself).

like image 40
baol Avatar answered Oct 26 '22 23:10

baol