Re: how to call Javascript function in .xsl file

Subject: Re: how to call Javascript function in .xsl file
From: Paul Prescod <papresco@xxxxxxxxxxxxxxxx>
Date: Sun, 08 Nov 1998 11:30:47 -0600
Amit Rekhi wrote:
> 
> Why should adding HTML JavaScript code to template be a problem.
> Can't I have a pattern rule like :-
> 
> <xsl:template match="/">
> <HTML>
>    <HEAD>
>      <SCRIPT LANGUAGE="JavaScript"><![CDATA[
>         function Test()
>         {
> ....
> 
> Is not this a valid template ?

It is valid, but the XML processor will probably not understand the
behaviour of the SCRIPT element. Thus it will presume that less-than
symbols should be entity-ized on output. But HTML browsers do not expect
this. The fundamental problem is that HTML is *NOT* XML compatible but the
output of an XSL processor is XML. A smart enough XML processor can embed
special knowledge about HTML and HTMLize the output, but they are not
required to.

XSL is for XML->XML transformations, not XML->HTML transformations. 

<grumble>The SCRIPT element was always broken. It was alternately defined
in ways that were incompatible with SGML and then used SGML features that
were widely deprecated. Now they've been officially deprecated (in XML)
and we're stuck with incompatibility.</grumble>

See:
http://www.w3.org/TR/REC-html40/appendix/notes.html#notes-specifying-data

 Paul Prescod  - http://itrc.uwaterloo.ca/~papresco

"The new revolutionaries believe the time has come for an aggressive 
move against our oppressors. We have established a solid beachhead 
on Friday. We now intend to fight vigorously for 'casual Thursdays.'
  -- who says America's revolutionary spirit is dead?


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


Current Thread