Altova Mailing List Archives

RE: [xsl] including javascript??

From: "Chris Bayes" <Chris@----------->
Date: 4/6/2001 2:31:00 AM
You don't tell us what doesn't work. I'm going to guess that you don't get
any output.
I presume you are doing a <xsl:call-template name="javascript_head" />
somewhere. If not then use match instead of name <xsl:template
match="javascript_head">. So then you will need a <javascript_head> element.
Let's assume you are getting into the template. The next problem might be
that the test is failing <xsl:when test="number(NAVIGATION/KAPITEL)=1"> is
saying if the numeric value of NAVIGATION/KAPITEL is 1 then output some
text. This will be true if you have the following xml

    <current context node>

If you don't have that structure then the test will be false and you will
get no output.
Here are 2 files that work fine.

<?xml version="1.0"?>

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

	<xsl:template match="javascript_head">
	<xsl:call-template name="javascript_head" />

	<!-- your template here -->


Ciao Chris

XML/XSL Portal

>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Marcus Klinge
>Sent: 06 April 2001 10:49
>To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>Subject: [xsl] including javascript??
>Hi there.
>I am currently sitting on a project that involves including javascript into
>the output HTML file.
>Sadly, my XSL does not seem to work properly.
>My code goes like this:
>	<xsl:template name="javascript_head">
>		<xsl:choose>
>			<xsl:when test="number(NAVIGATION/KAPITEL)=1">
>				<script language="JavaScript">
>					<xsl:comment>
>						 if (top.location
>!= window.location){top.location =
>						window.location;}
>						 //
>					</xsl:comment>
>				</script>
>				<script language="JavaScript"
>				<script language="JavaScript"
>			</xsl:when>
>		</xsl:choose>
>	</xsl:template>
>What am I doing wrong (as obviously I am)?
>Marcus Klinge
>Web Producing
>Karzauninkat Webdesign
>Barner Strasse 14
>22765 Hamburg
>Tel: 040 39834 771
>Fax: 040 39834 779
> XSL-List info and archive:

 XSL-List info and archive:


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.