Microsoft Knowledge Base Email Alertz

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.

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 291193 - Last Review: October 16, 2002 - Revision: 1.4

FIX: Reverse Axis Fails to Reverse Direction of Nodelist

This article was previously published under Q291193

On This Page

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  (http://kbalertz.com/Feedback.aspx?kbNumber=292935/EN-US/ ) 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 (http://msdn.microsoft.com/xml/default.asp)

MORE INFORMATION

Steps to Reproduce Behavior

  1. Create the XML document. The XML document refers to an XSL stylesheet.
    1. Create a new text document by using Microsoft Notepad or another text editor.
    2. Paste the following code into the new text document:
      <?xml version="1.0"?>
      <?xml-stylesheet href="Reverse.xsl" type="text/xsl"?>
      <Desks>
        <Desk id="First"/>
        <Desk id="Second"/>
        <Desk id="Third"/>
        <Desk id="Last"/>
      </Desks>
      						
    3. Save the text file as C:\Reverse.XML.
  2. Create the XSL stylesheet to process the XML document.
    1. Create a new text document by using Microsoft Notepad or another text editor.
    2. Paste the following code into the new text document:
      <?xml version="1.0"?>
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:output method="text"/>
      
      <xsl:template match="http://support.microsoft.com"> 
         <xsl:for-each select="(//Desk)[last()]">
           <xsl:for-each select="(preceding-sibling::Desk)[1]">
                 Should be First, but it's <xsl:value-of select="@id"/>
           </xsl:for-each>
         </xsl:for-each>
      </xsl:template>
      </xsl:stylesheet>
      						
    3. Save the text file as C:\Reverse.XSL.
  3. 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
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).

APPLIES TO
  • Microsoft XML Parser 3.0
Keywords: 
kbbug kbfix kbmsxml300sp1fix kbmsxmlnosweep KB291193
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate