Velocity Question

Syed O. Karimushan's Avatar

Syed O. Karimushan

16 Jul, 2015 05:14 PM


I am new to Cascade/Velocity and trying to implement a template with a format region.

My page structure as follows:

    <heading>My Test Page</heading>
        <p>This is a test page</p>
        <p>This is line 2 of my test page</p>
            <img alt="Graduate Program" height="206" src="/renderfile/0be89d6c82cbc818676c63701c2cccd2/images/dept-grad.jpg" width="340"/>
            <a href="/entity/open.act?type=page&amp;id=974da7e082cbc8180464c4e9d7c14e27&amp;confId=976c28c882cbc8180464c4e9f4060e95" target="_parent" title="Test">Link 1</a>
        <p>Link 2</p>

I am trying to pull the area named :

#set($data = $_XPathTool.selectSingleNode($contentRoot, "/system-data-structure"))
#set($sidebararea = $data.getChild("sidebar"))
#if($sidebararea != '')
    $_SerializerTool.serialize($sidebararea, true)


<!DOCTYPE html>
<html xmlns="" class="">
<system-region name="SCRIPT"/>
<title>Penn State Engineering: <system-page-title/></title>
<div style="position:fixed;top:0px;z-index:100000;left:auto;width:100%;"><system-region name="HEADER"/></div>
<div id="content_wrap">
<div class="gridContainer clearfix">
<div class="fluid" id="content">
<div class="fluid" id="interior_banner_image"><img alt="students and faculty working in lab" src="/images/interior-banner.jpg"/></div>
<div class="fluid" id="breadcrumbs"><system-region name="BREADCRUMBS"/></div>
<div class="fluid" id="interior_main">
<div class="fluid" id="interior_main_left"> </div>
<div class="fluid" id="interior_main_content">
<div class="adjust_right_margin"><system-region name="DEFAULT"/></div>
<div class="fluid" id="interior_main_sidebar"><system-region name="SIDEBAR"/></div>
<div class="fluid" id="interior_main_right"> </div>
<div class="fluid" id="interior_imagebar_3-3-6"><system-region name="STORIES"/></div>
<div id="footer"><system-region name="FOOTER"/></div>

When I load the page, I get this error:

An error occurred: Could not transform with Script format "_cascade/Formats/Sidebar Content": org.apache.velocity.exception.MethodInvocationException: Invocation of method 'selectSingleNode' in class org.jdom.xpath.JaxenXPath threw exception java.lang.NullPointerException at velocityTransform-1437065514587[line 1, column 26]

You may choose to retry the operation<javascript:location.reload(false)>. If the problem persists, please contact a system administrator.

The error has been logged to the system console.

Can you please tell me what I am doing wrong? My data definition is very simple:

    <text identifier="heading" label="Page Heading"/>
    <text wysiwyg="true" identifier="content" label="Main Content"/>
    <text wysiwyg="true" identifier="sidebar" label="Side Bar Content"/>

Thank you very much.


Syed Karimushan
Information Systems
Penn State College of Engineering
[email blocked][email blocked]

  1. 1 Posted by Ryan Griffith on 16 Jul, 2015 05:38 PM

    Ryan Griffith's Avatar

    Hi Syed,

    The error you are encountering is due to the $contentRoot variable not being defined when you attempt to access it as the context in your $_XpathTool.selectSingleNode call.

    The reason this variable is not defined is most likely because you did not apply an Index Block to the region this Format is assigned to. Based on your Format, it looks like you will need to apply a calling page Index Block.

    Note: the DEFAULT region is an exception to this rule, where the calling page's structured data will be set to $contentRoot if there is no Block assigned to the region.

    Please let me know if you have any questions.


  2. 2 Posted by Syed O. Karimus... on 17 Jul, 2015 08:09 AM

    Syed O. Karimushan's Avatar

    Hi Rayn,

    Thanks for your reply – I got that part fixed (no error).

    Sorry to be a pain, but I am not able to pull the content on a page I just made. While I can pull the default content, but the sidebar region content is not showing. The “test format” shows the content properly:

    [cid:[email blocked]]

    So I am missing a step.



  3. 3 Posted by Ryan Griffith on 17 Jul, 2015 12:10 PM

    Ryan Griffith's Avatar

    Hi Syed,

    The issue now is you will most likely need to adjust the XPath you are using to obtain the structured data, now that you have added a calling page block.

    When you have a moment, try adjusting the following line:

    #set($data = $_XPathTool.selectSingleNode($contentRoot, "/system-data-structure"))


    #set($data = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure"))

    Please let me know if you have any questions.


  4. 4 Posted by Syed O. Karimus... on 17 Jul, 2015 06:27 PM

    Syed O. Karimushan's Avatar

    Hi Ryan,

    I got this to work. Thanks for your guidance.


  5. Support Staff 5 Posted by Tim on 17 Jul, 2015 06:35 PM

    Tim's Avatar

    Thanks for the update, Syed. I'm glad Ryan was able to help out. Take care!

  6. Tim closed this discussion on 17 Jul, 2015 06:35 PM.

Discussions are closed to public comments.
If you need help with Cascade CMS please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac


26 Aug, 2016 01:19 PM
25 Aug, 2016 03:02 PM
25 Aug, 2016 12:50 PM
24 Aug, 2016 08:43 PM
24 Aug, 2016 07:20 PM
21 Aug, 2016 01:20 PM