Sounds like a good addition to the util TagLib.
In the mean time, the code below can be turned into a tag using the define
TagLib like this:
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml"
xmlns:define="jelly:define" xmlns:http="notImplementedYet">
<define:taglib uri="textUtil">
<define:tag name="join">
<x:parse var="beansProject" xml="${file}" />
<x:set var="configs" trim="true"
select="$select"/>
<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="${var}" value="${inputs}${infile.text}"/>
</j:forEach>
</define:tag>
</define:taglib>
</j:jelly>
And then used like this:
<j:include uri="./myTagLib.jelly"/>
<textUtil:join file="<file>" select="<select>" var="<var>" />
I haven't tested this, so I might have made a coding error, but you get the
idea.
Hans
-----Original Message-----
From: marc & lan [mailto:[EMAIL PROTECTED]
Sent: Sunday, January 23, 2005 4:40 PM
To: Jakarta Commons Users List
Subject: Re: [jelly] XPath to comma-separated list?
> 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.
Sure it's no very pretty.
But I've searched for a "implode" php-like in Java, and there's not.
You can create a java class with a static method which does it
I'm thinking we need a set of text manipulation set inluding such a feature
<implode source="${src}" var="dest" sep=","/>
Marc
-
---------------------------------------------------------------------
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]