This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

JavaScript and XSL Problems


> Hi, I'm working on a project that will have a JavaScript menu generate along the side of the screen through XSL.  The way the JavaScript was written was so that it would have a list of fixed values.  Through XSL I'm attempting to make it generate specific to each XML document, to allow for easy navigation.  These documents are rather lengthy, which is why I'd like to put it in there.  My first attempts focused upon creating variables and passing them into the JavaScript, but after repeated attempts it didn't work.  So next, I used the <xsl:for-each> command (as it's based on a hierarchical structure, basically a Table of Contents) within JavaScript to go through the Table of Contents the right way.  After this, what I did was I created a function that would accept the proper values, and display it in the menu like how it's supposed to be.  The problem I'm getting is that it doesn't populate correctly, as I get some funky errors saying that it's missing a ")" in the javascrip!
t text embedded into the XSL file, and a "]" in one of the javascript files (there are two).  I'm going to paste in the code segment that I have in the XSL file, and the corresponding code in the javascript file where it's supposed to read it in.
> 
> XSL Code Fragment:
> 
> <xsl:template match="//sectiontitle" mode="toc">
> 	<script type="text/javascript">
> 			collectData(<xsl:value-of select="count(//sectiontitle)+count(//title)+count(//subtitle)"/>, l, <xsl:value-of select="normalize-space(.)"/>);
> 			l++;
> 	<xsl:for-each select="..//title">
> 			collectData(<xsl:value-of select="count(//sectiontitle)+count(//title)+count(//subtitle)"/>, l, <xsl:value-of select="normalize-space(.)"/>);
> 			l++;
> 		<xsl:for-each select="..//subtitle">
> 			collectData(<xsl:value-of select="count(//sectiontitle)+count(//title)+count(//subtitle)"/>, l, <xsl:value-of select="normalize-space(.)"/>);
> 			l++;
> 		</xsl:for-each>
> 	</xsl:for-each>
> 	</script>
> </xsl:template>
> 
> JavaScript Code Fragment:
> 
> // ssmItems[...]=[name, link, target, colspan, endrow?] - leave 'link' and 'target' blank to make a header   
> ssmItems[0]=["Menu"] //create header
> function collectData(counter, a, link)
> {
> 	var i=1
> 	do
> 	{
> 		ssmItems[a]=["\"" + link + "\", \"#" + link "\", \"\""]
> 		i++;
> 	}while(i <= counter)
> 	buildMenu();
> }
> 
> 
The way the list is supposed to be populated is by having a string in this format:

ssmItems[1]=["CNN", "http://www.cnn.com";, ""]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]