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

RE: Looping and assigning into variable

Subject: RE: Looping and assigning into variable
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 29 Mar 2002 21:29:41 -0000
michael kay xslt concat array
I'm completely confused. This seems to be XSLT code that is generating
JavaScript code, except that it contains some <comment> elements. There's
nothing wrong with the XSLT code, but I've no idea whether the JavaScript
that you are generating makes any sense at all.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Meiyu Lin
> Sent: 28 March 2002 19:29
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject: RE:  Looping and assigning into variable
>
>
> Hi Michael,
> This is just what I am looking for but I just tried the following:
> var categorySelect = new Array(30);
> var driverName = new Array(30);
> var driverDesc = new Array(30);
>
>    <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>
>
> 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.
>
> Meiyu
>
> -----Original Message-----
> From: Michael Kay [mailto:michael.h.kay@xxxxxxxxxxxx]
> Sent: Thursday, March 28, 2002 8:54 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Looping and assigning into variable
>
> > How can I do this in XSLT?
>
> Not by trying to update a variable, that's not the way XSLT works.
>
> Do it like this:
>
> <xsl:variable name="commentVar">
>   <xsl:for-each select="Header">
>     <xsl:value-of select="Comment"/>
>   </xsl:for-each>
> </xsl:variable>
>
> <Comments>
>   <xsl:value-of select="$commentVar"/>
> </Comments>
>
> Of course, you might not need a variable at all, you can just do the
> xsl:for-each inside the <Comments> element.
>
> In XPath 2.0 / Saxon 7.0, you can just do:
>
> <Comments>
>   <xsl:value-of select="Header/Comment" separator=""/>
> </Comments>
>
> Michael Kay
> Software AG
> home: Michael.H.Kay@xxxxxxxxxxxx
> work: Michael.Kay@xxxxxxxxxxxxxx
>
> >
> > 	<xsl: variable name="CommentVar"/>
> >
> > 	<xsl:for-each select="Header">
> >
> > 		<!-- here i would like to get the current 'Comment'
> > value and
> > 			concatenate with the previous comment value
> > through above 'CommentVar', something like below-->
> > 		<xsl:value-of
> > select="CommentVar=concat(Comment,$CommentVar)"/>
> >
> > 	</xsl:for-each>
> >
> > 	<!-- here I would like to get the concatenated list of all
> > 'Comment' values -->
> > 	<Comments>
> > 		<xsl:value-of select="$CommentVar"/>
> > 	</Comments>
> >
> > Basically Each 'Header' element has 1 'Comment' child element
> > in it. So
> > I have to loop through all headers and finally get the
> > complete list of
> > concatenated 'Comment's
> >
> >
> > Thanks in advance..
> > VENKAT
> >
> >  XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
>


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

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


 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.