RE: [xsl] tag with one blank body

Subject: RE: [xsl] tag with one blank body
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 5 Jan 2010 13:07:21 -0000
> I've the need to generate in the output xml this tag with 
> exactly one space inside the body:
> 
> <QCat> </QCat>
> 
> I've tried this in the xstl:
> 
> <QCat><!-- DataType: Alphanumeric 
>                              Length: 2 
>                              Left justified. Blank fill if not used 
>                              --><xsl:value-of select=' '/></QCat>

That should give you a syntax error. The select attribute must contain an
XPath expression. But select="' '" should work.
> 
> and this
> 
> <QCat><!-- DataType: Alphanumeric 
>                              Length: 2 
>                              Left justified. Blank fill if not used 
>                              --><xsl:text> </xsl:text></QCat>
> 

This should work. If it doesn't, there's something odd going on. Perhaps
you're parsing the stylesheet using the Microsoft XML parser which is a bit
cavalier in throwing out whitespace? If that's the case, see if
<xsl:text>&#x20;</xsl:text> works.

Or perhaps the XSLT stylesheet is generating the space and you're not seeing
it because of how you view the output?

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

Current Thread