Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 291135 - Last Review: August 12, 2005 - Revision: 2.4
FIX: XPath Name Function with a Namespace Node Returns Prefix
This article was previously published under Q291135
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.
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:
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
- Create the XML document. The XML document refers to an XSL stylesheet.
- Create a new text document by using Microsoft Notepad or another text editor.
- 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>
- Save the text file as C:\XPATHname.XML.
- Create the XSL stylesheet to process the XML document.
- Create a new text document by using Microsoft Notepad or another text editor.
- 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 = "http://support.microsoft.com">
<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>
- Save the text file as C:\XPATHname.XSL.
- 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
| kbbug kbfix kbmsxml300sp1fix kbmsxmlnosweep KB291135 |
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