RE: Literal Text

Subject: RE: Literal Text
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 29 Mar 1999 10:55:44 +0100
Title: RE: Literal Text

> Given this XSL:
>
> <xsl:text>&lt;/JPanel&gt;</xsl:text>
>
> When run through Lotus XSL Processor I get this output:
>
> &lt;/JPanel&gt;
>
> When I really want:
>
> </JPanel>
>
> What am I doing wrong?
>
Misunderstanding one of the underlying concepts of XSL, which is that it produces a tree rather than a stream of characters.

If it's of any interest, SAXON's "almost-XSL" processor does allow you to produce any stream of characters, including XML, HTML, badly-formed-XML, and things-that-aren't-XML-at-all. If you have a valid reason for wanting the characters "</JPanel>" in your output, you can do it in two ways in SAXON:

1: <xsl:tag>/JPanel</xsl:tag>

or

2: <xsl:text saxon:escape="no">&lt;/JPanel&gt;</xsl:text>

The former approach is there primarily to handle the case where you do want to output well-formed XML, but you have to suppress compile-time checking to achieve it (rather like a cast). An example would be:

  <xsl:if test=".[first-of-type()]">
    <xsl:tag>JPanel</xsl:tag>
  </xsl:if>
        ...
  <xsl:if test=".[last-of-type()]">
    <xsl:tag>/JPanel</xsl:tag>
  </xsl:if>

The second approach is there primarily to handle the case where the output is not *ML at all, e.g. it might be a CSV file.

Mike Kay

Current Thread