commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. Matthew Pryor" <>
Subject [jelly] XML element nesting out of order
Date Wed, 13 Nov 2002 17:54:28 GMT

I really appreciate all your help; I am making good progress. I took out
my default namespace and that unblocked me for now.

This time I have another issue and I am not sure if the fault is mine or

Here is my goal:
    <jj:goal name="update-version">
      <x:parse var="feature" xml="feature.xml"/>
      <x:element name="feature">
        <x:forEach select="$feature/feature/@*">
            <x:set var="thename" select="local-name()"/>
            <x:set var="thevalue" select="string()"/>
                <j:when test="${thename == 'version'}">
                    <x:attribute name="${thename}">2.2.2</x:attribute>
        <x:copyOf trim="false" select="$feature/feature/*[local-name()
!= 'plugin']"/>

And here is the abbreviated result:

      Versata Business Logic Design Suite
      Copyright (c) 2002 Versata, inc. All Rights Reserved
      Empty License Agreement
   <update label="Versata Business Logic Plugin"
<feature id=""
label="" version="2.2.2"
provider-name="Versata, In
c." os="win32" ws="win32" nl="en" arch="x86" primary="true"></feature>
Total time:  3 seconds

So I succeeded in updating the version number, but for some reason, the
<feature/> element does not contain the other sub-elements

I nested the Jelly code to copy yhe sub-elemtns inside an <x:element/>
tag in the script, but perhaps I am misinterpreting the tags

TIA for any more help you can provide.

j. matthew pryor <>
versata, inc. <>

-----Original Message-----
From: James Strachan [] 
Sent: Wednesday, November 13, 2002 5:14 AM
To: J. Matthew Pryor
Cc: 'Jakarta Commons Developers'
Subject: Re: [jelly] XPath name() function broken in CVS ?

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
try to use local-name() instead as name() might include a namespace
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

The short answer to this problem is...

The reason for the failure is I broke it by accident recently when
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
(you can stop reading now if you like)...

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

<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
default namespace (the namespace with no prefix defined via the
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
URI other than "". If this does happen, the XPath functions (like
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