[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: loop without switching context

Subject: Re: loop without switching context
From: Fred Christian <fchristian@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Mar 2012 14:44:34 -0700
Re:  loop without switching context
Thanks Wendell, Michael and David,

I was able to learn a bit from each answer.

I got my transform working by using the proper form
    <xsl:variable name="x" select="."/>
instead of
    <xsl:variable name="x"><xsl:copy-of select="."/></xsl:variable>

I think I will finally brake that habit from my msxsl xslt 1.0 days.

And I can see your point about the term "loops". It can set up a
misunderstanding. One that I have helped others though while teaching
xslt, so I should know better.

Thanks,
Fred

On Fri, Mar 23, 2012 at 9:02 AM, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
wrote:
>
> 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'"/>
>
> Cheers,
> Wendell
>
> ======================================================================
> Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc.                http://www.mulberrytech.com
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.