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

RE: Possible MSXML 3 / 4 bug: using a for-each on xsl

Subject: RE: 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 10:20:51 -0400
xsl for each child
thanks Oleg for the help ... I'll be giving the "usual trick" a shot!  

Thanks,
Jeff

-----Original Message-----
From: Oleg Tkachenko [mailto:olegt@xxxxxxxxxxxxx]
Sent: Tuesday, May 14, 2002 11:13 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Possible MSXML 3 / 4 bug: using a for-each on
xsl:variable / tre e-frag is misbehaving


Hello!

I believe that's not a bug at all, its fully specification-defined
behaviour.
"/xml/an-element" expression means select all an-elements children of xml 
elements etc *in the same document as the context node*. The context node in

the place is item element in a result tree frag (temporary tree), so that 
expression selects nothing.
You can use usual trick - save original document root in a variable and use
it 
when you need access to the tree:

       <xsl:variable name="root" select="/"/>
       <xsl:for-each select="msxsl:node-set($items)/item">
         <using_msxsl_node-set child-id="{@id}">
           <xsl:copy-of select="$root/xml/an-element"/>
         </using_msxsl_node-set>
       </xsl:for-each>

-- 
Oleg Tkachenko
Multiconn International, Israel


Jeff Beadle wrote:

> 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"?>
> <xml>
> <an-element>
>    <child id="child01"/>
>    <child id="child02"/>
> </an-element>
> <collection>
>    <item id="item01"/>
>    <item id="item02"/>
> </collection>
> </xml>
> 
> 
> Here's the xslt:
> 
> <?xml version="1.0" ?>
> <xsl:stylesheet version="1.0" exclude-result-prefixes="msxsl"
>       xmlns:msxsl="urn:schemas-microsoft-com:xslt"
>       xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>    <xsl:output method="xml" indent="yes" encoding="utf-8"/>
>    <xsl:template match="/">
>       <output>
>          <xsl:variable name="items" >
>             <xsl:copy-of select="//item"/>
>          </xsl:variable>
>          <xsl:for-each select="msxsl:node-set($items)/item">
>             <using_msxsl_node-set child-id="{@id}">
>                <xsl:copy-of select="/xml/an-element"/>
>             </using_msxsl_node-set>
>          </xsl:for-each>
>          <xsl:for-each select="//item">
>             <NOT_using_msxsl_node-set child-id="{@id}">
>                <xsl:copy-of select="/xml/an-element"/>
>             </NOT_using_msxsl_node-set>
>          </xsl:for-each>
>       </output>
>    </xsl:template>
> </xsl:stylesheet>
> 
> 
> Here's the output (I get):
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <output>
>    <using_msxsl_node-set child-id="item01" />
>    <using_msxsl_node-set child-id="item02" />
>    <NOT_using_msxsl_node-set child-id="item01">
>       <an-element>
>          <child id="child01" />
>          <child id="child02" />
>       </an-element>
>    </NOT_using_msxsl_node-set>
>    <NOT_using_msxsl_node-set child-id="item02">
>       <an-element>
>          <child id="child01" />
>          <child id="child02" />
>       </an-element>
>    </NOT_using_msxsl_node-set>
> </output>
> 
> 
> If this is not a user error/bug and truly is a bug within msxml, then this
> one really [expletive deleted].
> 
> 
> 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
> objects/results.
> 
> 
> So, has anyone encountered this "issue"?


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

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


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.