Jelly is extremely powerful (as is Java), but I personally prefer using xmltask. Here's how you would modify an attribute:
<xmltask source="input.xml" dest="out.xml"> <attr path="web/servlet/[EMAIL PROTECTED]'4']/" attr="id" value="test"/> </xmltask> looks simpler to me (provided you are ok adding a new jar to your build classpath!). -Vincent > -----Original Message----- > From: Paul Libbrecht [mailto:[EMAIL PROTECTED] > Sent: 09 July 2003 13:42 > To: Maven Users List > Subject: Re: Jelly question > > Well, with jelly, you can easily modify a stream of SAX events. > > But you can definitely parse a document, store it in a variable, modify > it (accessing it using XPath for example) then re-output it... > > Down here is such a snippet, it parses a bunch of files together and > re-outputs it in one file... > > Do note that if you're using DTDs or Schemas, the default values > specified there will come in... > > Also, do not that jelly has a strong tendency to ignore all whitespace > by default (the trim attribute just about everywhere) which may or may > not be wished... > > Paul > > <?xml version="1.0" encoding="utf-8" ?> > > <j:jelly > xmlns:j ="jelly:core" > xmlns:log ="jelly:log" > xmlns:x ="jelly:xml" > xmlns:ant ="jelly:ant" > xmlns:util="jelly:util" > xmlns:b="jelly:beanshell" > > > > <log:info>Constructing File scanner.</log:info> > <ant:fileScanner var="blopFiles"> > <ant:fileset dir="." includes="blop/**/dependency.xml"/> > </ant:fileScanner> > > <log:info>File scanner constructed.</log:info> > <!-- - amalgamate all files within one object --> > <x:parse var="all_files"> > <my:allFiles xmlns:my="myNamespace"> > <j:forEach var="file" items="${blopFiles.iterator()}"> > <j:set var="url" value="${file.toURL()}"/> > <log:info>Going around ${url}</log:info> > <my:file > href="${url.toExternalForm()}"> > <j:include uri="${url.toExternalForm()}"/> > </my:file> > </j:forEach> > </my:allFiles> > </x:parse> > > > <!-- do something on there like something using > x:forEach which goes around XPath elements --> > > <j:file name="someFile.xml" outputMode="HTML" ><!-- > prettyPrint="yes" > --> > <x:copyOf select="$all_files"/> > </j:file> > > </j:jelly> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]