XSLT : For-each

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Not sure if this is the right forum, but does anybody have any experience of
using a XSLT variable in a xsl:for-each loop.

As in, I want to pass in a variable called source which itself holds the
root of the data I wish to loop through.

<xsl:for-each select = "$source">
' Do something
</xsl:for-each>
 
You use a template. Example:

<xsl:template select="XPathToElements">
<!-- whatever you want to do -->
</xsl:template>

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 
Not really the right group, but..

<xsl:variable name="xpath" select="//link" />

<xsl:for-each select="$xpath">

</xsl:for-each>


should work

now, if you want the variable to be driven from ASP.NET, ur in a totally
different league. You pretty much need to rename your xsl to aspx, make your
xml file point to the aspx file, change the content type of yoru aspx file
to whatever xsl needs to be and then you can simply use something like

select="<%=myXPath%>"


Karl
 
Redowl said:
Hi,

Not sure if this is the right forum, but does anybody have any experience of
using a XSLT variable in a xsl:for-each loop.

As in, I want to pass in a variable called source which itself holds the
root of the data I wish to loop through.

<xsl:for-each select = "$source">
' Do something
</xsl:for-each>

There is a microsoft.public.xsl group which has tons of QA. You could
become an XSL expert just following along in that group. This for-each
question is answered many times over in that group. Very high
signal/noise there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top