[xsl] Escaping <xsl:element> ouput

Subject: [xsl] Escaping <xsl:element> ouput
From: Anirvan Majumdar <anirban.majumdar@xxxxxxxxxxxxx>
Date: Thu, 07 Aug 2008 14:08:02 +0530
Hello,

I have a <xsl:variable> element which contains HTML snippet. Parts of this snippet are generated by transformations of other XSLT elements present.
Next on, I'd like to take this <xsl:variable>'s value and apply some string manipulation templates on it. I realized that if I wanted to extract the value inclusive of tags then I needed to include the HTML code, and not the XSLT code, within <![CDATA]]> sections. Everything seemed to be going fine until I realized that all the content generated through the <xsl:element>s was missing. The tags are ignored and only the node value is captured.


How can I get around this problem? I checked and there is no way for output escaping in <xsl:element>, and neither is there any point of putting the code within <[CDATA[]]> since the transformations won't occure only.

I also thought of using <xsl:copy-of> to extract the variable value, but this isn't of much use to me, since the data extracted through copy-of cannot be used for any further processing as such. I can only display this value [something like <xsl:value-of>]

Here's an example of the kind of XSL I'm working on:
<xsl:variable name="someVar">
<![CDATA[
<span id="1">
<input type="text" value="A" name="txtVal"/>
]]>
<xsl:element name="input">
<xsl:attribute name="type">hidden<xsl:attribute>
<xsl:attribute name="value">[some value computed before]</xsl:attribute>
</xsl:elelement>
<![CDATA[
</span>
]]>
</xsl:variable>


Current Thread