commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Hans Gilde <hgilde-comm...@earthlink.net>
Subject RE: [jelly] XPath to comma-separated list?
Date Sun, 23 Jan 2005 22:47:38 GMT
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:marclan@free.fr] 
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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


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