[xsl] XSL within HTML javascript

Subject: [xsl] XSL within HTML javascript
From: "Jason Lustig" <lustig@xxxxxxxxxxx>
Date: Sat, 30 Nov 2002 16:45:23 -0500
Hi everyone

I'm fairly new with XSL, and am working on a decently large project with
it. I'm creating a number of skins for a web design that is written in
XML, with HTML embedded. It's working fine for the most part, and I'm
working on a skin where it takes the navigation information (that's in
the xml) and transforms it into some javascript that'll make some DHTML
menus.

The XML for the nav looks something like this:

<navigation>
	<navigation-group name="Home" id="home">
		<item url="./main.asp" id="homeitem">Home</item> 
	</navigation-group>
	<navigation-group name="General Information" id="generalinfo">
		<item url="./upcomingprograms.asp"
id="upcomingprograms">Upcoming Programs</item> 
		<item url="./news.asp" id="news">Chapter News</item> 
		<item url="./list.asp" id="list">Announcements
Listserv</item> 
	</navigation-group>
</navigation>

... and I have (within an XSL template) this code:


<script>
oCMenu.makeMenu('cyptop','','Chapter Yellowpages','{$base}');

	<xsl:apply-templates select="./navigation"/>
</script>


Now, my problem is that when the parser (MSXML 3) goes through this part
of the XSL, it doesn't parse it -- it just spits out what's within the
<script></script> tags. The {$base} doesn't turn into the base URI
(which is defined as a global variable earlier in the XSL file), and my
<xsl:apply-templates/> tag isn't parsed at all -- it is spit out exactly
the way it is in there. The HTML, as it comes out of the XSL script when
it's parsed, looks like this:

<script>
oCMenu.makeMenu('cyptop','','Chapter Yellowpages','{$base}');

	<xsl:apply-templates select="./navigation"/>
</script>


... which is (obviously) exactly what the XSL is, when it's **supposed**
to parse the XSL and turn it into the javascript that is going to make
the menus. So the problem (at least what it looks like to me) is that it
doesn't parse XSL within a javascript <script></script> block.

Is there any way to fix this? It doesn't make sense that it would be
acting like this; I don't know why a <script></script> block would be
any different than a <p></p> block or a <div></div> block. I've checked
over the archives, and all over the web, and I can't seem to find an
answer to this problem... thanks in advance!

--Jason


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


Current Thread