Wednesday, September 22, 2004

Defining Entities in Xslt 

I am always forgetting how to define entities in xslt stylesheets. Here is a simple sample.

<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp '&#160;'>
]>

This is particularly relevant when trying to insert a non-breaking space with xslt--a particularly esoteric task. I have heard that setting the output to ASCII instead of UTF-8 will ensure that the above non-breaking space is included in the output. I believe &#A0; is the unicode character.

<xsl:output method="html" encoding="ASCII" omit-xml-declaration="no" version="4.0" />

Another option is this apparently, though I have heard it is not predictable.

<xsl:text>&amp;#160;</xsl:text>




Comments: Post a Comment

This page is powered by Blogger. Isn't yours?