tag:help-archives.hannonhill.com,2010-02-09:/discussions/velocity-formats/5532-oddityCascade CMS: Discussion 2018-10-18T20:36:58Ztag:help-archives.hannonhill.com,2010-02-09:Comment/287285722013-09-12T15:49:36Z2013-09-12T15:49:36ZOddity<div><p>Hi Jim,</p>
<p>Were you able to get this working? I was able to successfully
escape the two elements in my local Cascade Server 7.6
instance.</p>
<p>Please let me know if you have any questions.</p>
<p>Thanks!</p></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285722013-09-18T16:15:09Z2013-09-18T18:20:14ZOddity<div><p>Ryan,<br>
Back at it. I'm on 7.6. This isn't working.<br>
Here's what I've noted:</p>
<p>If I have the xml escape in the script for the header and use
&, it doesn't render and in the XML view of the page the &
has been changed to the ASCII: <code>&amp;</code></p>
<p>If I enter <code>&amp;</code> it escapes the character and
displays <code>&amp;</code></p>
<p>As the same escape clause is used twice on the page and only
works in the second instance.</p>
<p>I'm befuddled.<br>
Jim</p></div>steelejtag:help-archives.hannonhill.com,2010-02-09:Comment/287285722013-09-19T18:49:52Z2013-09-19T18:49:52ZOddity<div><p>Hi Jim,</p>
<blockquote>
<p>If I have the xml escape in the script for the header and use
&, it doesn't render and in the XML view of the page the &
has been changed to the ASCII: <code>&amp;</code></p>
</blockquote>
<p>This is correct, Cascade Server will encode the ampersand when
generating the structured data to ensure the content is valid
XML.</p>
<blockquote>
<p>If I enter & it escapes the character and displays &</p>
</blockquote>
<p>This would be expected because the ampersand will be encoded,
leaving you with <code>&amp;amp;</code>, which is valid
XML.</p>
<p>I was able to get things working using the following setup:</p>
<p><strong>Data Definition</strong></p>
<pre>
<code>
<system-data-structure>
<text identifier="title"/>
<group identifier="subsection" multiple="true">
<text identifier="heading"/>
<text wysiwyg="true" identifier="content"/>
</group>
</system-data-structure></code>
</pre>
<p><strong>Format</strong></p>
<pre>
<code>#set ($dd = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure"))
#set ($header = ${_EscapeTool.xml($dd.getChild('title').value)})
#set ($subs = $_XPathTool.selectNodes($dd, "subsection"))
<h2>${header}</h2>
#foreach ($sub in $subs)
#set ($heading = ${_EscapeTool.xml($sub.getChild('heading').value)})
#set ( $content = $sub.getChild("content"))
#if ($heading.trim() != "")
<h3>${heading}</h3>
#end
<p>$_SerializerTool.serialize($content, true)</p>
#end</code>
</pre>
<p><strong>Values Entered on Page</strong></p>
<p>Title: <code>Conferences & Registration</code><br>
Heading: <code>test of &</code></p>
<p><strong>Resulting HTML</strong></p>
<pre>
<code><h2>Conferences &amp; Registration</h2>
<h3>test of &amp;</h3>
<p>When coordinating registration for an event, at least two weeks before the conference deadline for registration, organizations should prepare a list of all participants and submit an OrgSync request before meeting with their Campus Life advisor. Organizations must provide their Campus Life advisor with all necessary information about participants, which may include copies of driver&#8217;s licenses, birthdates, and/or W numbers.</p></code>
</pre></div>Ryan Griffithtag:help-archives.hannonhill.com,2010-02-09:Comment/287285722013-09-19T19:35:25Z2013-09-19T19:35:25ZOddity<div><p>Ryan,<br>
As is usual, this was my error. I was in the middle of writing an
explanation that the escape tool was working in both fields as
evidenced in the XML output, but kicked an error when I tried to
view it in HTML. Then I reread the error. It appears I set this
page up to use the data-defined title value in the page title
meta-tag which does not react well to an ampersand. That was what
was crashing my HTML view. I just used the replaceAll() method for
the page title format to replace the & with "and." Working now.
I'll read my error messages more attentively from now on.</p>
<p>Thanks<br>
Jim</p></div>steelej