[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: JavaScript and XSL Problems

Subject: Re: JavaScript and XSL Problems
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 19 Jul 2002 10:10:59 +0100
javascript normalize
Hi Puneet,

>> 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>

If you look at the JavaScript generated by this code, you'll see
something along the lines of:

  <script type="text/javascript">
    collectData(12, l, a lot of text...);
    l++;
    collectData(12, l, some more text...);
    l++
    collectData(12, l, yet more text...);
    l++;
    ...
  </script>

I suspect that the problem is that the third argument to your
collectData function, as you're generating it, hasn't got any quotes
around it. If you change those lines that generate the
"collectData(...)" call to:

  collectData(
    <xsl:value-of select="count(//sectiontitle)+count(//title)+count(//subtitle)"/>,
    l,
    "<xsl:value-of select="normalize-space(.)"/>");

So that double quotes are generated around the last argument, you
might have better luck.

By the way, are you sure that you want the first argument to be the
same for each call to the collectData() function?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.