Well.. first things first.
Without seeing your loop construction, it's a bit hard to
determine the problem.
Here's a sample I adjusted from your second
scenario:
<%
String str = ''
[1..10].flatten().each{
str = str +
'<event>' + it + xwiki.getXMLEncoded('this one\n')+ '</event>\n'
}
println(str)
%>
The
result when shown in a standard XWiki page for this (just stuck it in a page),
is predictable enough; no linebreaks and the <event /> tag is ignored
since it thinks it's a custom element.
Could
you expand a bit more on what output you're getting, and what you're doing with
it after (putting it in a field/passing it to xml/etc)?
Here's
what I get:
---
1this
one2this one3this one4this one5this one6this one7this one8this one9this
one10this one
---
From: users-bounces@xwiki.org
[mailto:users-bounces@xwiki.org] On Behalf Of BOUSQUET
Jeremie
Sent: 24 January 2008 16:05
To:
users@xwiki.org
Subject: [xwiki-users] Groovy and getXMLEncoded()
question
Hello,
I’m having a headache trying to
understand why those 2 pieces of groovy do not generate exactly the same thing
:
1)-
<%
// LOOP 10
times
println (
‘<event>’ + xwiki.getXMLEncoded(blablabla) + ‘</event>’
)
// END LOOP
%>
2)-
<%
str =
‘’
// LOOP 10
times
str = str +
‘<event>’ + xwiki.getXMLEncoded(blablabla) + ‘</event>\n’
// END LOOP
println(str)
%>
“blablabla” is a formatted text (in
my case, the description field of an article for example).
1) produces what is expected : it
writes 10 lines of text, beginning with ‘<event>’, and special characters
in “blablabla” are correctly translated.
2) produces any number of lines
(> 10), because carriage returns inside “blablabla” have not been translated,
and so many lines are written for each line
expected.
I ‘m not sure if this is the right
place for this, but if someone as an idea it would greatly help me
…
Best
Regards,
Jeremie