Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 262125 - Last Review: October 15, 2002 - Revision: 1.3
FIX: XSL "/" Pattern Returns Each Node Twice from a Linked XML Document
This article was previously published under Q262125
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.
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.
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
(http://msdn.microsoft.com/xml/default.asp)
.
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="http://support.microsoft.com//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.
| kbbug kbfix kbmsxml250fix kbmsxmlnosweep KB262125 |
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