Help required in XSLT

Here should go questions about transforming XML with XSLT and FOP.
Posts: 2

Help required in XSLT

Mon Jan 24, 2005 6:07 pm

I am using XSLT to launch a popup from a link in my JSP page (XML data).
It works great for all the cases except for the links where the link name
contains a single quote character (something like CIELO D'AMERICA).

I have 2 java script functions which are called by the XSLT.

My code sample is as follows:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">


<SCRIPT language="JavaScript">
function openWindow(url)
var vesselWin = (url,"newWindow","toolbar=no,width=300,height=200,scrollbars=yes,resize=yes,menubar=no");

function openWindow(url,param1,param2,param3)
url = url + '&amp;name1='+param1+'&amp;name2='+param2+'&amp;code='+param3;
var myWin2 =,"newWindow","toolbar=no,width=300,height=200,scrollbars=yes,resize=yes,menubar=no");


The above Java script functions are called as follows.

<A class="linkUnderline" >
<xsl:attribute name="HREF">javascript:openWindow('<xsl:value-of select="normalize-space(./test/infolink)"/>');</xsl:attribute>
<FONT COLOR="#000000" ><xsl:value-of disable-output-escaping='yes' select="./test/name"/></FONT>

<A class="linkUnderline" >
<xsl:attribute name="HREF">javascript:openWindow('<xsl:value-of select="normalize-space(../link)"/>','<xsl:value-of select="normalize-space(../../../test/name)"/>','<xsl:value-of select="normalize-space(../../../testname2)"/>','<xsl:value-of select="normalize-space(../../../test/code)"/>' );</xsl:attribute>
<FONT COLOR="#000000" ><xsl:value-of select="../stopdate"/></FONT>

Any help will be highly appreciated.

Thanks in advance.
Site Admin
Posts: 2100

Thu Jan 27, 2005 5:03 pm


I think your problem is related with the fact that you generate an invalid Javascript code. If I remember correclty you need to escape the apostrophe as \' . If your code can work if you remove the apostrophes then you can use translate to remove it, otherwise you can use a replace template to replace ' with \' . For such a template see the XSLT FAQ:

Best Regards,
Posts: 2

Sun Jan 30, 2005 2:51 am


Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 1 guest