[xsl] Possible MSXML 3 / 4 bug: using a for-each on xsl:variable / tre e-frag is misbehaving

Subject: [xsl] Possible MSXML 3 / 4 bug: using a for-each on xsl:variable / tre e-frag is misbehaving
From: Jeff Beadle <Jbeadle@xxxxxxxx>
Date: Tue, 14 May 2002 09:34:50 -0400
Howdy all,

I looked through the archives and went to Microsoft's msxml site and
couldn't find any "PRB" or "BUG" reports regarding this "issue".

Here's what I'm seeing:  Within an xsl:for-each element, where the select is
made against an xsl:variable tree-frag, xpath statements are failing to
nodes outside of the given for-each's context.

Here's the xml:

<?xml version="1.0"?>
   <child id="child01"/>
   <child id="child02"/>
   <item id="item01"/>
   <item id="item02"/>

Here's the xslt:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl"
   <xsl:output method="xml" indent="yes" encoding="utf-8"/>
   <xsl:template match="/">
         <xsl:variable name="items" >
            <xsl:copy-of select="//item"/>
         <xsl:for-each select="msxsl:node-set($items)/item">
            <using_msxsl_node-set child-id="{@id}">
               <xsl:copy-of select="/xml/an-element"/>
         <xsl:for-each select="//item">
            <NOT_using_msxsl_node-set child-id="{@id}">
               <xsl:copy-of select="/xml/an-element"/>

Here's the output (I get):

<?xml version="1.0" encoding="utf-8" ?>
   <using_msxsl_node-set child-id="item01" />
   <using_msxsl_node-set child-id="item02" />
   <NOT_using_msxsl_node-set child-id="item01">
         <child id="child01" />
         <child id="child02" />
   <NOT_using_msxsl_node-set child-id="item02">
         <child id="child01" />
         <child id="child02" />

If this is not a user error/bug and truly is a bug within msxml, then this
one really sucks.

I can think of workarounds but they're a major pain in the you-know-what.

... oh, and for those will immediately ask:  "Can you re-design the code not
to use a variable?"  Nope, I can't ...  well, I'm pretty sure I can't.
Within the real code, I have to build and work with temporary

So, has anyone encountered this "issue"?


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread