This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
dynamically generating JavaScript using XSLT
- To: "Xsl-List (E-Mail)" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] dynamically generating JavaScript using XSLT
- From: Sebastian Schirmer <schirmer at sitewaerts dot de>
- Date: Fri, 31 Aug 2001 21:27:13 +0200
- Reply-To: xsl-list at lists dot mulberrytech dot com
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"/>&DV=<xsl:value-of
select="@derivative"/>&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"><</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">></xsl:text>");
<xsl:apply-templates /> <!-- Image goes here -->
<xsl:text
disable-output-escaping="yes"></a></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