Hi,
It's technically Monday here (yesterday was a bank holiday), so
hopefully I understand the question correctly!
Easiest way would be to escape the "'" itself when used in the relevant
place. You can escape "'" with a double quote using the .replace()
string command.
For example:
#set($t_sSQLQuery="this is ${t_sUserName}'s query")
#set($t_sSQLQuery=$t_sSQLQuery.replace("'", "''"))
This is not the shortest way - but it is the more flexible way to do
this; and ensures you can still update your query along the way if
needed.
Thus, your snippet
#set ($query = "where doc.name like '%--%'")
Would become
#set($docname="document'sname")
#set($docname=$docname.replace("'", "''")
#set ($query = "where doc.name like '%${docname}%'")
**In case you missed it, "${velocity_variable_without_the_dollar_sign}"
is the formal method of accessing a variable's value; it allows you to
build up strings using variables directly as demonstrated above.
-----Original Message-----
From: xwiki xwiki [mailto:xwiki@xiancaro.com]
Sent: 05 June 2007 13:37
To: xwiki-users(a)objectweb.org
Subject: [xwiki-users] how to find out incorrect named pages
Hi,
here I have a problem with a xwiki 1.0 which upgraded from an existing
xwiki 0.9.840 which someone named a page like: "Jon's Pages" conflict
with the navagation panel's sql statement.
I did a velocity script but I don't find it support "[ ]" wildcard noted
in this reference manual:
http://manuals.sybase.com:80/onlinebooks/group-as/asg1250e/refman/%40ebt
-link;pt=26021?target=%25N%15_26195_START_RESTART_N%25
since I just want to select where name not like mywhitelisted
characters.
the blacklisted characters should be those used by xwiki syntax, and
those symbol used in sql statement like "'" """
any one know how to use the wildcard to done that?
or any other solutions?
Thx in advance!
I already have this:
#set ($query = "where doc.name like '%--%'")
{table}
Page Name | Author | date
#foreach ($item in $xwiki.searchDocuments("${query}"))
##if ($xwiki.hasAccessLevel("view", $context.user,
"${context.database}:${item}"))
#set($bentrydoc = $xwiki.getDocument($item))
[${bentrydoc.web}.$bentrydoc.name] |
$xwiki.getLocalUserName($bentrydoc.author) |
$xwiki.formatDate($bentrydoc.date, $dateFormat) ##end #end {table}
Muzi