Hi Gerritjan,
On Wed, Nov 16, 2011 at 5:11 PM, Gerritjan Koekkoek <
gerritjankoekkoek(a)gmail.com> wrote:
Hi,
I'm converting a XML file into XWiki pages with a structured object, my
problem is that the XML file might contain elements with problematic text
I have a XSLT that gives me a velocity script (like below)
{{velocity}}
##Creating a ATE Question and Answer document programatically
#set($ATEPrefix = "CdLSATE")
#set($ATEDocName = $ATEPrefix+'TE'+1001)
#set($newATEQA =
$xwiki.getDocument("CdLSATEPublic.$ATEDocName"))
##Set a title
$newATEQA.setTitle("Teeth Exfoliation")
##Set parent of document to Public ATE Questions and Answers
$newATEQA.setParent("CdLSATEPublic.CdLSATEPublicQAs")
##This is how you can use a template
$newATEQA.setContent('{{include
document="CdlsatdCode.CdLSATEPublicQATemplate"/}}')
##Create a new object on the document
#set($newATEQAObject =
$newATEQA.newObject("CdlsatdCode.CdLSATEPublicQAClass"))
##Set a field to a particular value
$newATEQAObject.set("AlphabetSort","TE")
$newATEQAObject.set("subject","Teeth Exfoliation")
$newATEQAObject.set("question","Is early loss of baby teeth
something to be concerned about, indicative of a bigger problem, or related
to CdLS?")
$newATEQAObject.set("language","en")
$newATEQAObject.set("CountryCode","us")
$newATEQAObject.set("answer","
It is normal for children, especially girls, to lose their
lower two front teeth from 4.5 years old to 5.5 years old. 4.5 years is
early, but can be considered normal. There seems to be quite a variety of
times when children with CdLS find themselves loosing their primary or baby
teeth. Children with CdLS can have their primary teeth fall out either
early or, more often, late. If the child is four years old and there are no
other underlying medical complications, such as, hypothyroidism,
hypophosphatsia, etc., then I would not be too concerned about losing the
teeth. If there were many teeth, including molars that are getting loose,
then further investigations would be indicated.
DM/ TK 7-13-10
SEE ALSO: Teeth Grinding 1 Teeth Grinding 2 Teeth
Growth Teething")
$newATEQAObject.set("SACApproved",1)
$newATEQA.save()
{{velocity
$newATEQAObject.set("question","...") and
$newATEQAObject.set("answer","...") give me challeges
Some text elements (not this example) will contain characters or
combination of characters that will have a effect;
- on the script not being valid; the " (double bracket) character
You need to make sure, when generating the quoted strings, to replace
quotes (") with $escapetool.quote or $escapetool.q and single quotes (')
with $escapetool.singleQuote or $escapetool.s. Example:
$newATEQAObject.set("answer","Then the robot says: ${escapetool.q}Hello
World!${escapetool.q}")
Anything else, besides quotes or single quotes, should have no impact on
the validity of your velocity script, as long as your string is wrapped by
quotes.
- having a XWiki 2.0 meaning; "--" ,
"**" but intending something else
You only care about this at the presentation level, not here, at set level.
This means that, in your sheet, you might want to display the values of
"question" and "answer" inside a verbatim like:
{{velocity}}
#set ($a = "**a**")
{{{ $a }}}
{{/velocity}}
This will escape any wiki syntax that might be contained by the values of
"question" and "answer".
Help appreciated...
Hope this is what you were asking for.
Thanks,
Eduard
Gerritjan
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users