This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Printing out variables with escaped text.


I'm having a problem printing out variables that contain text
declared with disable-output-escaping="yes" (and yes, I'm doing
dodgy stuff, trying to create start and end tags where I
shouldn't, before anyone tells me I shouldn't be doing this.)

Consider the following stylesheet - it surprised me that this
didn't work.

--- START
<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

<xsl:output method="html" />

<xsl:template match="/">
  <xsl:variable name="bob">
    <xsl:text>&lt;fake_element_no_escaping&gt;
</xsl:text>
    <xsl:text disable-output-escaping="yes">&lt;fake_element_escaping&gt;
</xsl:text>
  </xsl:variable>
  <xsl:value-of select="$bob" />
</xsl:template>

</xsl:stylesheet>
--- END

The output from both Saxon and Xalan was (actually Saxon didn't bother
escaping the &gt;'s, but that's OK for now.)

&lt;fake_element_no_escaping&gt;
&lt;fake_element_escaping&gt;

So I pulled out the spec and it suggested using <xsl:copy-of> instead of
<xsl:value-of>.

So I tried that and got :

Saxon:

&lt;fake_element_no_escaping>
&lt;fake_element_escaping>

Xalan:

&lt;fake_element_no_escaping&gt;
<fake_element_escaping>

which is what I originally wanted.

It's getting pretty hard to find bugs in Saxon nowadays, so I thought I'd
post this to list instead of straight to Mike, to see if anyone had any
thoughts on what is the correct behaviour here - the spec doesn't appear
to address this issue specifically.

Any comments? Thanks.

-- 
Warren Hedley
Department of Engineering Science
Auckland University
New Zealand


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]