This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
for-each sort of thing in {} ?
- To: xsl-list at mulberrytech dot com
- Subject: for-each sort of thing in {} ?
- From: "Carole E. Mah" <carole at goon dot stg dot brown dot edu>
- Date: Thu, 8 Jun 2000 11:58:46 -0400 (EDT)
- Reply-To: xsl-list at mulberrytech dot com
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[position()=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@Brown.edu
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