RE: [xsl] XSL template "namespace" problem

Subject: RE: [xsl] XSL template "namespace" problem
From: Ian Bonnycastle <ibonny@xxxxxxxxxxxx>
Date: Wed, 29 Mar 2006 13:31:08 -0500 (EST)
On Wed, 29 Mar 2006, Michael Kay wrote:

One
snippet of XSLT code I'm using as an example is:

<A NAME="linkone"><xsl:attribute
name="HREF">javascript:process('linkone',<xsl:value-of
select='/rootnode/value'/>)</xsl:attribute>Click me, value
is: <xsl:value-of select="/rootnode/value" />.</A>

(Notice the <xsl:value-of> tag inside the Javascript call
inside the A
HREF, and inside the A HREF data field.)

This is now well-formed (though not very pretty) XML, and it's correct XSLT. The HTML it generates is slightly dubious, because javascript:process(.....) is not a legal URL, so some HTML validators may get upset about it (and the XSLT serializer will replace spaces by %20, which would probably stop it working); you may be better off generating attributes like onClick that are designed to hold Javascript rather than URLs.

This is all well and good, but then that means that there is no way to create javascript-linked links in XSLT. The reason I'm doing it this way is because I'm trying to create a menu system that is based on an XML file to define its content. Unfourtunately, using a structure like:


<A OnClick="funccall()">Some text</A>

doesn't create a clickable link, even though it might be more "well formed" than:

<A HREF="javascript:funccall()">Some text</A>

This latter code actually creates a link that one can click on. From what I'm understanding, this type of structure, because its not well formed, is completely incompatible with XSLT, even thought xsltproc processes it properly and IE interprets it correctly. I guess I'm a little confused why these browsers and processors are interpreting it if its technically illegal.

Ian

Current Thread