Michael,

Have a look in the code at:
jelly-tags/xml/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
In there you'll see a method setAsString which sets a flag (so you can use the attribute "asString='true'").
That flag currently implies "single='true'" but that could be changed to suit exactly what you wish: as string should not only convert one result to string but a comma (or "${separator}") separated list.


Willing to give a try ?
It looks easily doable to me.

paul


Le 23 janv. 05, � 21:03, Michael Schuerig a �crit :

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:[EMAIL PROTECTED]       twice, it usually doesn't strike once.
http://www.schuerig.de/michael/  --Salman Rushdie, Fury

---------------------------------------------------------------------
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]



Reply via email to