commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [jelly] XPath name() function broken in CVS ?
Date Wed, 13 Nov 2002 13:13:48 GMT
Hi Matthew

BTW in future could you prefix your mails to commons-dev or commons-user
with [jelly]? It just helps folks figure out which bit of the commons
project you're talking about. (We should document this fact on the Jelly

From: "J. Matthew Pryor" <>
> Hi
> This worked fine with beta-7
> <x:copyOf trim="false" select="$feature/feature/*[name() !=
> 'requires']"/>
> But now with beta-8 CVS build (as of 10 minutes ago) I get the
> following:
> update-version:
> [ERROR] Function :name
> Total time:  2 seconds
> The XPath expression is OK isn't it?
> Did I do something incorrectly?

Your XPath expression is totally fine. Though a quick piece of XPath advice,
try to use local-name() instead as name() might include a namespace prefix.
Having a dependency on the namespace prefixes used in an XML document is
considered bad form; only the local name and the namespace URI should count

The short answer to this problem is...

The reason for the failure is I broke it by accident recently when adding
some new namespace aware XPath features to Jelly - many appologies. I've
created a JellyUnit test case to demonstrate the bug

and the bug is now fixed in CVS. There's a new Jelly snapshot build
containing this fix, so rebuild Maven and you should be OK.

Now here's the longer explanation of what went wrong and how its been fixed
(you can stop reading now if you like)...

I recently added support for namespaces inside XPath expressions, so that
you can use any namespace prefix in scope inside an XPath expression. e.g.

<whatever xmlns:x="jelly:xml" xmlns:my="someNamespaceURI">
    <x:parse var="doc">
    <x:forEach select="$doc/my:foo/my:bar">

However the recent changes to support the above introduced a bug whereby the
default namespace (the namespace with no prefix defined via the xmlns="..."
XML attribute) was being passed from the Jelly document into the
NamespaceContext used to evaluate the Jaxen XPath expressions. This is a
bug. The NamespaceContext should never map an empty prefix to a namespace
URI other than "". If this does happen, the XPath functions (like name())
disappear as they are registered via the "" namespace URI.

I suspect the Jelly document you were using had xmlns="..." defined which is
why the XPath expression was failing. I've now fixed this issue by
explicitly ignoring the default namespace when constructing a Jaxen


Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message