Re: [xsl] XPath and noname namespace

Subject: Re: [xsl] XPath and noname namespace
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Jul 2008 11:03:34 -0400
At 2008-07-14 16:52 +0200, Adam Komisarek wrote:
I have found workaround but I wonder why it must be done in that way..
Is it some kind of bug in XPath?

It is not a bug.

I have simple document:<svg xmlns="";>
<a>aadsf</a> </svg>

And now "//a" doesn't find a node.. I must use //*[local-name() =

No, it isn't a requirement that you do it that way .. and what you have is ambiguous. What you have would also find anchors in the HTML namespace if they were also in your document.

In your stylesheet declare the SVG namespace and you can use it in XPath:


In XSLT 2.0 you can declare xpath-default-namespace= in order to set a default in XPath.

The prefix used in the stylesheet has no relation to the prefix used in your users' data files ... they just need to be pointing to the same namespace URI.

but funny thing is that //*[name() = 'a'] works as well.. Why is

That is poor form and should be avoided because it relies on your knowledge of the prefixes (or lack thereof) being used by your users. Your users might be using "svg:a" properly and what you have wouldn't work for you.

I hope this helps.

. . . . . . . . . Ken

Upcoming XSLT/XSL-FO hands-on courses:      Wellington, NZ 2009-01
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds:     publicly-available developer resources and training
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread