XSLT: Disable output escaping in an entire document.

Posted by Kragen on Stack Overflow See other posts from Stack Overflow or by Kragen
Published on 2010-05-07T12:16:03Z Indexed on 2010/05/07 12:18 UTC
Read the original article Hit count: 330

Filed under:
|

I'm trying to generate some C# code using xslt - its working great until I get to generics and need to output some text like this:

MyClass<Type>

In this case I've found that the only way to emit this is to do the following:

MyClass<xsl:text disable-output-escaping="yes">&lt;</xsl:text>Type<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

Where:

  • Often it all needs to go on one line, otherwise you end up with line breaks in the generated code
  • In the above example I technically could have used only 1 <xsl:text />, however usually the type Type is given by some other template, e.g:

<xsl:value-of select="@type" />

I don't mind having to write &lt; a lot, but I would like to avoid writing <xsl:text disable-output-escaping="yes">&lt;</xsl:text> for just a single character!

Is there any way of doing disable-output-escaping="yes" for the entire document?

© Stack Overflow or respective owner

Related posts about code-generation

Related posts about xslt