FIX: XPath Name Function with a Namespace Node Returns Prefix (291135)



The information in this article applies to:

  • Microsoft XML 3.0

This article was previously published under Q291135

SYMPTOMS

When applied to a namespace node, the XPATH name function returns the prefix (such as xmlns:) as part of the name, at the front of the name.

In contrast, the local-name function does not return the prefix as part of the name of the namespace node.

The name and local-name functions should return the same string when applied to a namespace node.

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:

MORE INFORMATION

The W3C XPath Specification, located at the following Web site states:

"NOTE: The string returned by the name function will be the same as the string returned by the local-name function, except for element nodes and attribute nodes."

Because the namespace node is neither an element nor an attribute, the name and local-name functions should return the same string.

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="XPATHname.xsl" type="text/xsl"?>
      <bookstore specialty="novel" xmlns:dt="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882/"
      xmlns:my="urn:http//www.placeholder-name-here.com/schema/">
               <my:book style="wonderful" princess="true">
       	<my:title>Who's Who in Charlotte</my:title>
         	<my:author>Stephanie Bourne</my:author>
          </my:book>
      </bookstore> 
      						
    3. Save the text file as C:\XPATHname.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 version="1.0"   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:dt="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882/"
        xmlns:my="urn:http//www.placeholder-name-here.com/schema/">
          <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
          <xsl:template match = "/">
             <xsl:apply-templates select = "bookstore/my:book"/>
          </xsl:template>
          <xsl:template match = "my:book">
               name: <xsl:value-of select="name(namespace::*)"/> <BR/>
               local-name: <xsl:value-of select="local-name(namespace::*)"/>
          </xsl:template>
      </xsl:stylesheet> 
      						
    3. Save the text file as C:\XPATHname.XSL.
  3. Open the XML document in Microsoft Internet Explorer (IE) to process the XML document by using the XSL stylesheet. The following output shows that name and local-name functions return different strings:

    name: xmlns:xml
    local-name: xml


Modification Type:MajorLast Reviewed:8/12/2005
Keywords:kbBug kbfix KbMSXML300SP1fix kbMSXMLnosweep KB291135