Re: [xsl] loop without switching context

Subject: Re: [xsl] loop without switching context
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Fri, 23 Mar 2012 12:02:50 -0400
Hi Fred,

First off (this is totally minor) there are those among us who get nervous when people refer to "loops" in XSLT, which they really aren't. (I realize that even loops aren't loops, but still.)

For the main business:

On 3/22/2012 7:36 PM, Fred Christian wrote:
The loop works, but it switches my context so that template "a" no
longer has the xml it needs.
I realized I could pass in the context node as a param, but it seems
that is only giving me access to children and not ancestors of the
context node.

The usual solution to your problem is to bind the node needed to a variable outside the for-each, so it is available inside it. And, as you say, it can be passed as a parameter into any other templates.

When this is done correctly, you do have access to the node, its children and ancestors.

This leads me to think something is going wrong in code you aren't showing us.

BTW, you will get better performance, and avoid potential headaches, if instead of

<xsl:with-param name="x">01</xsl:with-param>

you say

<xsl:with-param name="x" select="'01'"/>


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML

Current Thread