Re: [xsl] Looping and assigning into variable

Subject: Re: [xsl] Looping and assigning into variable
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Thu, 28 Mar 2002 14:56:20 -0800
You are outputting HTML, right?  I'm noticing the <comment> element inside 
your for-each's.  This should probably be <xsl:comment>.  Also, I'm not 
seeing how the <comment>/<xsl:comment> is being placed inside of a <script>, 
which would be necessary in order for the browser to know that it is, well, a 
script.

If that doesn't help, then what I'd recommend to do is look at the output 
your stylesheet is currently giving.  I mean, look at the actual HTML source 
that the browser is seeing.  Then, save that HTML to a normal file and edit 
it until it works in the browser the way you want.  Finally, look at whatever 
changes you had to make and adjust your stylesheet to match those changes.

On Thursday 28 March 2002 14:09, Meiyu Lin wrote:
> Hi Peter,
>
> Here is what I have, the following <textarea ... is in my project.xsl
> This is transformNode from an ASP.
>
> <?xml version='1.0'?>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
> <xsl:template match="/">
> <html>
> <head>
> <title>Modify Project</title>
> <script><xsl:comment><![CDATA[
>  var techInd = 0;
>  var append = 0;
>
> all my script goes to here
> function InitAllVariables ()
> {
>    for (var i = 0; i<30;==i)
>    {
>       categorySelect[i] = "";
>       driverName[i] = "";
>       driverDesc[i] = "";
>       ......
>    }
> }
> ]]></xsl:comment></script>
> </head>
> <BODY>
> <!---
> DO SOMETHING HERE
> <xsl:apply-templates />
> -- >
> </BODY>
> </html>
> </xsl:template>
> <xsl:template match="projSummary">
>   <textarea ID="driverNameEdit" class="driverNameEditDesc"
> rows='5'></textarea><br />
>   <textarea ID="driverDescEdit" class="driverDescEditDesc"
> rows='5'></textarea><br />
> ... more textarea
>
>    <xsl:for-each select= "driverlist">
>    <comment>
>       categorySelect[techInd] = '<xsl:value-of select="category" />'
>       driverName[techInd] = '<xsl:value-of select="drivername" />'
>       driverDesc[techInd++] = '<xsl:value-of select="driverdesc" />'
> 	</comment>
>    </xsl:for-each>
>    <xsl:for-each select= "bsqapplist">
>    <comment>
>       categorySelect[appInd] = '<xsl:value-of select="bsqappcategory" />'
>       driverName[appInd] = '<xsl:value-of select="bsqappname" />'
>       driverDesc[appInd++] = '<xsl:value-of select="bsqappdesc" />'
>    </comment>
>    </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> //===========xml data file===========
> < projSummary>
> ...
> <driverlist>
> <category>Driver Category</category>
> <drivername>Driver Name</drivername>
> <driverdesc>Driver Description</driverdesc>
> </driverlist>
> <bsqapplist>
> <bsqappcategory>Application Category</bsqappcategory>
> <bsqappname>Application Name</bsqappname>
> <bsqappdesc>Application Description</bsqappdesc>
> </bsqapplist>
> ....
> </projSummary>
>
> Meiyu
> -----Original Message-----
> From: Peter Davis [mailto:pdavis152@xxxxxxxxx]
> Sent: Thursday, March 28, 2002 1:39 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: [xsl] Looping and assigning into variable
>
> On Thursday 28 March 2002 11:29, Meiyu Lin wrote:
> > I tried
> >       categorySelect[techInd] = <xsl:value-of select="category" />
> > The results for the vars are undefined.  Could you tell me what did I do
> > wrong?  Thank you.
>
> I'd like to see the output of your stylesheet before I guess at this too
> much, but I'm wondering what the initial value of "techInd" and "appInd"
> are.
>  Do you have: "var techInd = 0, appInd = 0;" anywhere?  If you do, please
> post some example input/output.  If not, then that means that "techInd" is
> being initialized to "undefined", which also means that "techInd++"
> probably
>
> wouldn't work.

-- 
Peter Davis
A businessman is a hybrid of a dancer and a calculator.
		-- Paul Valery

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


Current Thread