LiveSite XSL Reference II

28 November 2008
by Billy Czajkowska

Nested Quotations with XSL
It is not unusual to come across a situation where nested quotations fail (are exceeded) in an apperance XSL document.
Say I want to tie a Javascript function to an input control, but I want to pass the value of a datum-type as an argument to the funtion.
Therefore I want to describe an attribute value something of the order “JavaScript:handleJSFunction (‘//Datum[@Name=”someDatum”]’);”
In practice this will fail as the nested quotes will not resolve (and CDATA will not work either, it will generate errors).
The solution is to take the theoretical expression:
<input type=”checkbox” name=”cb_boolean1″ value=”false” onClick=”JavaScript:handleJSFunction (‘//Datum[@Name=”someDatum”]’);”/>
and break out the expression using <xsl:attribute/> tags, then using <xsl:text/> together with <xsl:value-of/> to concentatate the attribute string value with the required Datum value (s), thus avoiding interpolation errors::
<input>
<xsl:attribute name=”type”><xsl:text>checkbox</xsl:text></xsl:attribute>
<xsl:attribute name=”name”><xsl:text>cb_boolean1</xsl:text></xsl:attribute>
<xsl:attribute name=”value”><xsl:text>false</xsl:text></xsl:attribute>
<xsl:attribute name=”onClick”>
<xsl:text>JavaScript:handleJSFunction(‘</xsl:text>
<xsl:value-of select=”//Datum[@Name=’someDatum’]”/>
<xsl:text>’);</xsl:text>
</xsl:attribute>
</input>
 

Our Latest News