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

RE: for-each sort of thing in {} ?

Subject: RE: for-each sort of thing in {} ?
From: Ben Robb <Ben@xxxxxxxxxx>
Date: Thu, 8 Jun 2000 17:23:55 +0100
xsl postition
If you put it in a variable, you should be able to do it... try:

<xsl:template match="foo">

<xsl:variable name="qstring">
	<xsl:for-each select="bar">
		<xsl:if test="postition() != 1">
			&amp;
		</xsl:if>
		id<xsl:value-of select="position()"/>=<xsl:value-of
select="@id"/>
	</xsl:for-each>
</xsl:variable>

<a href="foo.php3?{$qstring}">Link here!</a>

</xsl:template>

Not tested for well-formedness etc, but it should work.

Ben


> -----Original Message-----
> From: Carole E. Mah [mailto:carole@xxxxxxxxxxxxxxxxxx]
> Sent: 08 June 2000 16:59
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: for-each sort of thing in {} ?
> 
> 
> 
> I've currently got something like:
> 
> <foo>
>  <bar id="farble1">
>  <bar id="farble2">
>  <bar id="farble3">
> </foo>
> 
> And I want to grab all these id's and put them on an anchor's 
> HREF value,
> saving them as query paramters like this:
> 
> <a href="foo.php3?id1=farble1&id2=farble2&id3=farble3">
> 
> To do this, I have:
> <xsl:template match="foo">
>  <a 
> href="foo.php3?
> id1={bar/@id}&amp;id2={bar[position()=2]/@id}&amp;id3={bar[pos
> ition()=3]/@id}">
> 
> </xsl:template>
> 
> This works quite well.
> 
> However, the number of <bar> elements inside any given <foo> 
> element in
> any given document instance may vary  (this is (bar+) in the 
> content model
> for <foo>).
> 
> What I really want then, is whatever (if it exists) the XSLT 
> equivalent in
> a <a href="foo.php3?{FOR-LIKE-THING}"> of this PHP-ish FOR idea: 
>   $hrefValue = "";
>   for (i=0;i<last();i++) {
>     $appendMe = "&amp;id$i=bar/@id";
>     # concatenate next id to href string
>     $hrefValue .= $appendMe;
>    }
> 
> I hope this analogy makes sense ( .= is the concatenation operator in
> PHP).
> 
> thanks,
> -carole
> - - - - - - - - - - - - - - - - - - - - - - - - - - - 
>   Carole E. Mah                Carole_Mah@xxxxxxxxx
>               Senior Programmer/Analyst
>     Brown University Scholarly Technology Group
>                   phn 401-863-2669
>                   fax 401-863-9313
>               http://www.stg.brown.edu/
> personal: http://www.stg.brown.edu/staff/carole.html
> 
> 
> 
>  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.