FIX: XSL "//" Pattern Returns Each Node Twice from a Linked XML Document (262125)



The information in this article applies to:

  • Microsoft XML 2.0

This article was previously published under Q262125

SYMPTOMS

The MSXML 2.0 parser returns each node in the Document Object Model (DOM) two times when the XSL search pattern "//" is used. This occurs only when an XSL stylesheet is used to transform a linked XML document.

RESOLUTION

To work around this problem, upgrade to the MSXML 2.5 or later parser, or use explicit search patterns rather than the "//" pattern to retrieve nodes from a linked XML document.

STATUS

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

This bug has been corrected in version 2.5 of the MSXML parser. To download the latest version of the parser, go to http://msdn.microsoft.com/xml/default.asp.

MORE INFORMATION

Steps to Reproduce Behavior

To reproduce this behavior, insert the following code into a new document, and save the document as repro.xsl:
<HTML xmlns:xsl="http://www.w3.org/TR/WD-xsl">
  Using "xsllink/XML/ITEM", each node is returned one time.
  <TABLE BORDER="3">
    <xsl:for-each id="select" select="xsllink/XML/ITEM">
    	<TR>
    	  <TD><xsl:value-of select = "SUBITEM1" /></TD>
    	  <TD><xsl:value-of select = "SUBITEM2" /></TD>
    	  <TD><xsl:value-of select = "SUBITEM3" /></TD>
    	</TR>
    </xsl:for-each>
  </TABLE>

  In MSXML 2.0, this "//ITEM" outputs every node two times.
  <TABLE BORDER="3">
    <xsl:for-each id="select" select="//ITEM">
    	<TR>
    	  <TD><xsl:value-of select = "SUBITEM1" /></TD>
    	  <TD><xsl:value-of select = "SUBITEM2" /></TD>
    	  <TD><xsl:value-of select = "SUBITEM3" /></TD>
    	</TR>
    </xsl:for-each>
  </TABLE>
</HTML>
				
Insert the following code into a new document, and save it in the same location as the previous document as data.xml:
<XML xmlns:dt="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882/">
	<WWITEM>
		<SUBITEM1>1</SUBITEM1>
		<SUBITEM2>2</SUBITEM2>
		<SUBITEM3>3</SUBITEM3>
	</WWITEM>
</XML>
				
Finally, insert the following code into a new document, and save it in the same location as the previous two documents as bug.xml:
<?xml:stylesheet type="text/xsl" href="repro.xsl"?>
<XML xmlns:dt="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882/">
	<WWITEM>
		<SUBITEM1>1</SUBITEM1>
		<SUBITEM2>2</SUBITEM2>
		<SUBITEM3>3</SUBITEM3>
	</WWITEM>
</XML>
				
Using an Internet Explorer Web browser on a computer with version 2.0 of the MSXML parser installed, browse to the bug.xml file. The data returned from the query using the "//" pattern represents each node two times.

Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDSupport kbMSXML250fix kbMSXMLnosweep KB262125