/, XSL/LiveSite XSL Reference II

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::

<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:value-of select=”//Datum[@Name=’someDatum’]”/>



By |2008-11-28T22:30:32+00:00November 28th, 2008|LiveSite, XSL|0 Comments

About the Author: