Re: [xsl] Problems with for-each

Subject: Re: [xsl] Problems with for-each
From: "Kevin Nardi" <kevnardi@xxxxxxxxxxx>
Date: Thu, 12 Jul 2001 13:14:35 -0700
This is how I got around the problem...but is this the best way to do it? It seems rather haphazard...


<xsl:variable name="id">
<xsl:value-of select="identifier" />
<xsl:for-each select="//itemList/headerList/header">
<xsl:if test="name = 'title'">
<xsl:apply-templates select="//itemList/item/title[../identifier = $id]" />

From: "Kevin Nardi" <kevnardi@xxxxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Problems with for-each
Date: Thu, 12 Jul 2001 12:30:56 -0700

In an XSL stylesheet, I have a template with a code fragment that looks like

<xsl:template match="item">
		<xsl:for-each select="//itemList/headerList/header">
			<xsl:if test="name = 'title'">
				<xsl:apply-templates select="title" />

An <item> element looks like this:

	<title>Item 1</title>

My problem is that inside of the for-each loop, the context changes to that
of //itemList/headerList/header, and I lose the context of the current item
I'm working with, so the select="title" is invalid. How do I get my context


Get your FREE download of MSN Explorer at

XSL-List info and archive:

Current Thread