FIX: XML Pattern Match Fails When Using ID Attribute (262228)



The information in this article applies to:

  • Microsoft XML 2.0

This article was previously published under Q262228

SYMPTOMS

The MSXML 2.0 parser does not parse match patterns against ID attributes properly. The match pattern may not return any matches even when matches exist.

STATUS

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

This problem has been fixed in the MSXML 2.5 parser.

For more information, please see the following Microsoft Web site:

MORE INFORMATION

Steps to Reproduce Behavior

  1. Paste the following code into a new text document, and save it as idmatch.xml:
    <?xml version="1.0" ?>
    <?xml:stylesheet type="text/xsl" href="idmatch.xsl" ?>
    <XML xmlns="x-schema:idschema.xml">
    	<WWITEM id="foot1">
    		item1
    	</WWITEM>
    	<WWITEM id="foot2">
    		item2
    	</WWITEM>
    </XML>
    					
  2. Paste the following code into a new text document and save the document in the same location as the previous document, as idschema.xml:
    <?xml version="1.0" ?>
    <Schema xmlns="urn:schemas-microsoft-com:xml-data"
            xmlns:dt="urn:schemas-microsoft-com:datatypes">
      <AttributeType name="id" dt:type="id"/>
      <ElementType name="ITEM">
        <attribute type="id"/>
      </ElementType>
    </Schema>
    					
  3. Insert the following code into a new text document and save the document in the same location as the previous two documents, as idmatch.xsl:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
    	<xsl:template>
    	  <xsl:apply-templates/>
    	</xsl:template>
    	<xsl:template match="id('foot1')">
    	  FOOT1 FOUND<BR /><xsl:apply-templates/>
    	</xsl:template>
    	<xsl:template match="id('foot2')">
    	  FOOT2 FOUND<BR /><xsl:apply-templates/>
    	</xsl:template>
    </xsl:stylesheet>
    					
  4. Browse to the idmatch.xml file by using an Internet Explorer Web browser from a computer with version 2.0 of the MSXML parser installed, and note that the output is blank.
  5. Browse to the file again from a computer with version 2.5 of the MSXML parser installed, and note that the output contains two rows indicating that each match pattern was correctly identified.

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