[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] dynamically generating JavaScript using XSLT


Subject: [xsl] dynamically generating JavaScript using XSLT
From: Sebastian Schirmer <schirmer@xxxxxxxxxxxxx>
Date: Fri, 31 Aug 2001 21:27:13 +0200

Hello!

I want to dynamically generate JavaScript Code using a XSL Transformation,
but I dont know if it is possible at all:

The XSLT Code should look like the following snippet: (Pseudocode)


<xsl:template match="link[@targetcomponent = 'image']" priority="2">
	<script language="JavaScript">
		function <xsl:value-of select="@ID"/>()
		{
			var popWin =
window.open('go/imagedetailview?ID=<xsl:value-of
select="@ID"/>&amp;DV=<xsl:value-of
select="@derivative"/>&amp;COMP=<xsl:value-of
select="@targetcomponent"/><xsl:value-of
select="$sessionId"/>','Imagedetailview','width=400,height=400,locationbar=n
o,menuebar=no,status=no,scrollbars=1,resizable=1');
		}
							
		document.writeln("<xsl:text
disable-output-escaping="yes">&lt;</xsl:text>a
href=\"javascript:<xsl:value-of select="@ID"/>()\" target=\"_self\"
onMouseover=\"status=\'\';return true;\" onMouseout=\"status=\'\';return
true;\"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>");
		<xsl:apply-templates /> <!-- Image goes here -->

		<xsl:text
disable-output-escaping="yes">&lt;/a&gt;</xsl:text>
	</script>
</xsl:template>


The Problem is that I have to write the link using document.write() because
there will be a <noscript> part that will be displayed if a user has JS
disabled.

The output method has to be XML and cant be HTML. The output is written into
a JDOMResult, not into a StreamResult, so this makes the whole thing even
more complicated. I dont know how to solve this problem, maybe work with
CDATA sections, ... 


If anybody knows how to solve this, please let me know.


Sebastian Schirmer

<<<<<<<<<<<<<<<<<<<<<<<<<<<
sitewaerts GmbH
Hebelstraße 15
D-76133 Karlsruhe

Tel: +49 (721) 920 918 0
Fax: +49 (721) 920 918 29
http://www.sitewaerts.de
>>>>>>>>>>>>>>>>>>>>>>>>>>>



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



Current Thread
Keywords