commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Schuerig <mich...@schuerig.de>
Subject Re: [jelly] XPath to comma-separated list?
Date Sun, 23 Jan 2005 20:03:30 GMT
On Sunday 23 January 2005 20:37, marc & lan wrote:
> Michael Schuerig wrote:
> > I'm a Jelly beginner and haven't yet wrapped my head around it
> > completely. I'm looking for an idiomatic way to get from an XPath
> > to a comma-separated list of selected values.
> >
> > This is as far as I get
> >
> >    <x:parse var="cf" xml="file://${configfile}" />
> >    <x:set var="infiles" trim="true"
> >      select="$cf//configs/config"/>
> >
> > But then what?
>
> Coul you give us concret file please ? Do you have several
> configs/config nodes ? It's these values you want to set as
> comma-separated values ?

From a file with these contents

<beansProjectDescription>
  <configs>
    <config>src/main/webapp/WEB-INF/applicationContext1.xml</config>
    <config>src/main/webapp/WEB-INF/applicationContext2.xml</config>
  </configs>
</beansProjectDescription>

I want to extract a string with this content 
"src/main/webapp/WEB-INF/applicationContext1.xml,src/main/webapp/WEB-INF/applicationContext".xml"

Right now I'm using this code

    <x:parse var="beansProject" xml="${f}" />
    <x:set var="configs" trim="true"
      select="$beansProject/beansProjectDescription/configs/config"/>

    <j:forEach var="infile" indexVar="i" items="${configs}">
      <j:if test="${i gt 0}">
        <j:set var="inputs" value="${inputs},"/>
      </j:if>
      <j:set var="inputs" value="${inputs}${infile.text}"/>
    </j:forEach>

But for my taste this is much too pedestrian.

Michael

-- 
Michael Schuerig                 Not only does lightning not strike
mailto:michael@schuerig.de       twice, it usually doesn't strike once.
http://www.schuerig.de/michael/  --Salman Rushdie, Fury

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message