|
Subject: RE: for-each sort of thing in {} ? From: Ben Robb <Ben@xxxxxxxxxx> Date: Thu, 8 Jun 2000 17:23:55 +0100 |
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">
&
</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}&id2={bar[position()=2]/@id}&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 = "&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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| for-each sort of thing in {} ?, Carole E. Mah | Thread | XPointer support in document() ?, Dave Carlson |
| RE: MS chat tidbits, Paulo Gaspar | Date | RE: multilanguage support easily or, Kay Michael |
| Month |