Error occurring when selecting node

matthew.wren's Avatar


06 Jun, 2016 05:46 PM

I'm working on an email template and I have data definition field for the font size of the document. I was able to place this snippet of code in one of my format which is the body of the email:

#set( $fontSize = $_MathTool.toInteger(${_XPathTool.selectSingleNode($contentRoot, '/system-data-structure/body-font').value}))

then I just place ${fontSize} into the corresponding sections of the format.

I have the email styles in a separate format and I attempted to do the same thing but I got this error

An error occurred: Could not transform with Script format "emails/assets/Style": org.apache.velocity.exception.MethodInvocationException: Invocation of method 'selectSingleNode' in class org.jdom.xpath.JaxenXPath threw exception java.lang.NullPointerException at velocityTransform-1465235137313[line 63, column 49]

Do I have to use a different xpath expression to locate the node without error?

  1. 1 Posted by Ryan Griffith on 06 Jun, 2016 06:22 PM

    Ryan Griffith's Avatar

    Hi Matthew,

    Generally, you will see this error when attempting to use $contentRoot without applying an Index Block to the region along with the format. If there is no Index Block applied, $contentRoot is effectively a null object, so the XPath Tool method will throw an error.

    When you have a moment, please verify if you have an Index Block applied to the region.

    Please let me know if you have any questions.


  2. 2 Posted by matthew.wren on 06 Jun, 2016 06:36 PM

    matthew.wren's Avatar

    I actually do not. Neither does my other region and seems to work without a calling page block. When I do add an index block to my style format it does work though.

  3. 3 Posted by Ryan Griffith on 06 Jun, 2016 06:57 PM

    Ryan Griffith's Avatar

    Thank you form confirming, Matthew. If your other region is DEFAULT, the format is working because this region is slightly different in that if no Index Block is assigned the page's structured data will be applied to the $contentRoot variable.

    Please let me know if you have any questions.


  4. 4 Posted by matthew.wren on 06 Jun, 2016 07:19 PM

    matthew.wren's Avatar

    That's right I forgot! It is in the default region. thanks so much for this!

  5. 5 Posted by Ryan Griffith on 06 Jun, 2016 07:21 PM

    Ryan Griffith's Avatar

    Not a problem at all, Matthew. Glad to hear I was able to point you in the right direction.

    I'm going to go ahead and close this discussion, please feel free to comment or reply to re-open if you have any additional questions.

    Have a great day!

  6. Ryan Griffith closed this discussion on 06 Jun, 2016 07:21 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