Yes Thanks you, I had notice that ... after a little bit of reflexion :-)
I debuged like you said but with $escapetool.xml I didn't notice the problem because
Xwiki HTML rendering.
Thanks a lot for your help. :-)
Pascal B
________________________________
De : Eduard Moraru <enygma2002(a)gmail.com>
À : Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>fr>; XWiki Users <users(a)xwiki.org>
Envoyé le : Mercredi 8 octobre 2014 23h58
Objet : Re: [xwiki-users] Escape character with $stringtool.contains
Hi Pascal,
The problem is that you are searching for unescaped content inside escaped content. In
other words, $escapetool.xml called at the beginning escapes your "{" characters
to "{". Then you basically call
$stringtool.contains("{", "{") which will clearly be false.
It`s not a problem of $stringtool.contains, but on your code. Of course that (in your
second mail) $stringtool.contains("{", $escapetool.xml("{"))
returns true because it is the same thing as calling
$stringtool.contains($escapetool.xml("{"), $escapetool.xml("{"))
If you plan to do string matching on content, try to leave the escaping of the content
towards the end, when you actually have to display it and really need to escape it. Until
then, work with it unprocessed, as in #set($MyContent=$recentDoc.content)
You would have easily noticed the problem yourself if you would have tried printing the
value of $MyContent for debugging purposes and to see what it is actually that you are
trying to match. It is a good practice in general to double check your coding by printing
intermediary values of your code.
Happy coding!
-Eduard
On Wed, Oct 8, 2014 at 5:46 PM, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr> wrote:
... escapetool.xml is my new friend :-/
$stringtool.contains($MyContent,$escapetool.xml('{{box
cssClass="floatinginfobox" title="**Sommaire**"}}'))
________________________________
De : Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
À : XWiki Users <users(a)xwiki.org>
Envoyé le : Mercredi 8 octobre 2014 16h01
Objet : [xwiki-users] Escape character with $stringtool.contains
Hello,
On Xwiki 6.2.1, I'm fighting with $stringtool.contains
http://commons.apache.org/proper/commons-lang/javadocs/api-3.1/org/apache/c…
In my velocity code, I have
#set($MyContent=$escapetool.xml($recentDoc.content))
$MyContent return
{{box cssClass="floatinginfobox" title="**Sommaire**"}} {{toc
numbered="true" depth="3"/}} {{/box}} {{numberedheadings/}} Bla bla
I want to check if $MyContent contain this litteral string:
{{box cssClass="floatinginfobox" title="**Sommaire**"}}
I noticed than I can't escaping some characters ({ and ") with
$stringtool.contains
By example $stringtool.contains($MyContent,'box cssClass') working well but not
$stringtool.contains($MyContent,'{box cssClass')
I tried to escape characters with \ and/or ~ without success :-(
Have you got an idea?
thanks
Pascal B
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users