Re: (anti)XMLProcessing : how to render a list of node as a comma separated list of their text ?
Tim Diggins <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Hi Thierry -
Maybe I'm misunderstanding/missing something, but if your problem is
just the whitespace (the \n s)
you could (really simplistically) just put it all on one line:
<#assign x><#list bill.material as x>${x}<#if x_has_next>,</#if></
#list></#assign>
(NB: not sure why you need to do the assign in your example?)
but if you want to keep it on separate lines (easier to read after
all) then use the <#t/> (truncate leading/trailing whitespace on this
line):
<#assign x>
<#list bill.material as x><#t/>
${x}<#if x_has_next>,</#if><#t/>
</#list><#t/>
</#assign>
HTH Tim
On 18 Jun 2008, at 10:29, Daniel López wrote:
> Hi Thierry,
>
> Try using <#ftl strip_whitespace="true"> at the beginning of your
> template. At least that's what I use on my
> templates-that-process-XML-and-produce-JSON, which is also kind of
> picky
> with the newlines and spaces.
>
> S!
> D.
>
> thierry henrio escribió:
>> Hi all
>> I need to render something like
>>
>> data=
>> <bill>
>> <material>eggs</material>
>> <material>milk</material>
>> </bill>
>>
>> as
>> output=
>> "eggs,milk"
>>
>> at first, I though : "hey that does not look so difficult !!, that
>> will
>> be a matter of minutes" ...
>> so I wrote a learning test : 2 minutes
>> now, I must admit my learning test is still red after 2 hours :(
>>
>> so, is there anyone kind enough to teach me how to achieve this ??
>>
>> note 1:
>> i rapidly produced the following output
>> "eggs,
>> milk
>> "
>>
>> with template=
>> <#assign x>
>> <#list bill.material as x>
>> ${x}<#if x_has_next>,</#if>
>> </#list>
>> </#assign>
>> ${x}
>>
>> but these \n are killing my test !!
>>
>> note 2:
>> I'm angry to have to render in the xml output document something
>> like that
>> <property name="badDesignedDataModel" value="value1, value2,
>> value3"/>
>> where valueX are identified items in my xml data document
>> but that is it :)
>>
>> Regards, Thierry
>>
>>
>> ------------------------------------------------------------------------
>>
>> -------------------------------------------------------------------------
>> Check out the new SourceForge.net Marketplace.
>> It's the best place to buy or sell services for
>> just about anything Open Source.
>> http://sourceforge.net/services/buy/index.php
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> FreeMarker-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>
>
> --
> -------------------------------------------
> Daniel Lopez Janariz ([email protected])
> Web Services
> Centre for Information and Technology
> Balearic Islands University
> (SPAIN)
> -------------------------------------------
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> FreeMarker-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemarker-user
Tim Diggins
http://red56.co.uk/people/tim
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php