Microsoft KB Archive/291193

= FIX: Reverse Axis Fails to Reverse Direction of Nodelist =

Article ID: 291193

Article Last Modified on 10/16/2002

-

APPLIES TO


 * Microsoft XML Core Services 4.0

-



This article was previously published under Q291193



SYMPTOMS
When you use an XPath reverse axis to specify a nodelist, you find that the direction of the nodelist is not reversed. The XPath reverse axes include ancestor, ancestor-or-self, preceding, and preceding-sibling.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

This bug was corrected in Microsoft XML 3.0 Service Pack 1.

For additional information on other fixes included in Microsoft XML 3.0 Service Pack 1, click the article number below to view the article in the Microsoft Knowledge Base:

292935 INFO: List of Issues Fixed in Microsoft XML 3.0 Service Pack 1

For the latest information and downloads of MSXML, refer to the following MSDN Web site at:

http://msdn.microsoft.com/xml/default.asp



Steps to Reproduce Behavior
 Create the XML document. The XML document refers to an XSL stylesheet.  Create a new text document by using Microsoft Notepad or another text editor.  Paste the following code into the new text document:       <Desk id=&quot;Last&quot;/> </Desks> </li> Save the text file as C:\Reverse.XML.</li></ol> </li> Create the XSL stylesheet to process the XML document. <ol style="list-style-type: lower-alpha;"> Create a new text document by using Microsoft Notepad or another text editor.</li>  Paste the following code into the new text document: <?xml version=&quot;1.0&quot;?> <xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; version=&quot;1.0&quot;> <xsl:output method=&quot;text&quot;/>

<xsl:template match=&quot;/&quot;> <xsl:for-each select=&quot;(//Desk)[last]&quot;> <xsl:for-each select=&quot;(preceding-sibling::Desk)[1]&quot;> Should be First, but it's <xsl:value-of select=&quot;@id&quot;/> </xsl:for-each> </xsl:for-each> </xsl:template> </xsl:stylesheet> </li> Save the text file as C:\Reverse.XSL.</li></ol> </li> Open the XML document in Microsoft Internet Explorer (IE) to process the XML document by using the XSL stylesheet. Note that the following output specifies that preceding-sibling did not reverse the direction of the nodelist:

Should be First, but it's Third

</li></ol>

Note that preceding-sibling::Desk[1] should return Third and (preceding-sibling::Desk)[1] should return First. In MSXML 3.0 they both return Third, which is incorrect. The bug fix includes the second case; the first case should work in all releases. A workaround to force the second case to work in all releases is (preceding-sibling::Desk | nothing)[1] where nothing is an empty query (unused element name).

Keywords: kbbug kbfix kbmsxml300sp1fix kbmsxmlnosweep KB291193

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.