James you are awesome Thanks again !!
------------------------------------------------------------ j. matthew pryor <[EMAIL PROTECTED]> versata, inc. <www.versata.com> -----Original Message----- From: James Strachan [mailto:james_strachan@;yahoo.co.uk] Sent: Wednesday, November 13, 2002 11:35 AM To: J. Matthew Pryor Cc: 'Jakarta Commons Developers' Subject: Re: [jelly] XML element nesting out of order Hi Matthew From: "J. Matthew Pryor" <[EMAIL PROTECTED]> > James, > > 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 > not > > 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:choose> > <j:when test="${thename == 'version'}"> > <x:attribute name="${thename}">2.2.2</x:attribute> > </j:when> > <j:otherwise> > <x:attribute > name="${thename}">${thevalue}</x:attribute> > </j:otherwise> > </j:choose> > </x:forEach> > <x:copyOf trim="false" select="$feature/feature/*[local-name() > != 'plugin']"/> > </x:element> > </jj:goal> > > And here is the abbreviated result: > > update-version: > <description> > Versata Business Logic Design Suite > </description><copyright> > Copyright (c) 2002 Versata, inc. All Rights Reserved > </copyright><license> > Empty License Agreement > </license> > <url> > <update label="Versata Business Logic Plugin" > url="http://lynx.versata.com/lynx/builds/nightly"> > </update> > </url> > <feature id="com.versata.business.logic" > label="com.versata.business.logic" version="2.2.2" > provider-name="Versata, In > c." os="win32" ws="win32" nl="en" arch="x86" primary="true"></feature> > BUILD SUCCESSFUL > 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. I had a sneaky feeling you might hit this current limitation before I got chance to fix it :-). The code had a limitation that it didn't handle too well child content being output inside the <x:element>. So it couldn't handle nested <x:element> tags with <x:attribute> tags inside. I've fixed this issue in CVS and there's a new Jelly snapshot containing the fix. There is a limitation you should be careful of. You shouldn't output any text content before all the attributes have been defined. (This avoids having to buffer up the entire contents of the <x:element> tag before the attributes are output. So this is fine.. <x:element name="foo"> ... <x:attribute name="something" value="whatever"/> ... some text... <x:element name="bar" value="1234"/> ... however this will generate an exception <x:element name="foo"> some text <x:attribute name="x" value="1234"/> </x:element> I've added a new JellyUnit test case to test both nesting of elements with attributes and that the above does indeed throw an exception. James ------- http://radio.weblogs.com/0112098/ __________________________________________________ Do You Yahoo!? Everything you'll ever need on one web page from News and Sport to Email and Music Charts http://uk.my.yahoo.com -- To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>