Differences in Velocity versions, Cascade v.6 and .v.7

jperreault's Avatar


20 Nov, 2012 10:10 PM

Hi there,

We are in the midst of upgrading Cascade Sever 6.8 to 7.0.5. I've upgraded our test system to 7.0.5

But so far I've run into some differences in how our formats are being interpreted. For example, this code :

 #set ($subPage = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/system-folder[name='$parentFolder']/system-folder[name='$childFolder']/system-folder[name='$subFolder']/system-page[name='index']/display-name"))
 ## Let's assume that this sub-page does not exist, and subPage is undefined

 #if ($subPage != "" )

Version 6.8 Cascade Server displays "NO!"
Version 7.0.5 Cascade Server display "YES!"

Now, I understand the solution here is to not look for the empty string, and instead just check if the variable exists. This code evaluates the same in version 6 and 7 :

  #if ($subPage )

But my question is:

Are there any other common differences in the Velocity versions that other people have come across ?

Is there any good way to search/replace occurrences of these problems.


  1. 1 Posted by Ryan Griffith on 21 Nov, 2012 02:03 PM

    Ryan Griffith's Avatar


    I believe Velocity 1.7 evaluates null objects and empty strings differently than 1.5 did in Cascade 6.8.

    We have a link to the new features and changes between the two Velocity versions on this page in our issue tracker as well as some additional information about the new tools that were added in Cascade 6.10 on this page on our knowledgebase.

    One thing to note is the XPathTool returns a org.jdom.Element object and not necessarily a string so you could very well get some mixed results with $subPage != "" on an object.

  2. 2 Posted by jperreault on 22 Nov, 2012 06:37 PM

    jperreault's Avatar

    Thanks Ryan, the link to the Apache Velocity changelog is very helpful.

    I'm wondering if you have a suggestion about how we should fix this. I'm guessing we have used the !="" condition in many dozens of places.

    My current plan is to edit each format file one at a time, replacing the !="" string.

    Is there any better method to search and replace all of these files ?


  3. 3 Posted by Ryan Griffith on 26 Nov, 2012 01:18 PM

    Ryan Griffith's Avatar


    Not a problem at all, I'm glad your found the link to be helpful.

    You could try narrowing things down by using the Search and Replace and searching only Formats for != "" or !="" (place this in both the search and replace term fields). This should return all Formats containing that specific string.

    Please let me know if you have any questions.


  4. 4 Posted by jperreault on 06 Dec, 2012 07:21 PM

    jperreault's Avatar

    Hi Ryan,

    I could use some help constructing the search query.

    As you suggested, I want to search only our Format files for
    !="" OR != ""

    But think I need to escape some of these characters. None of these seem to work :

    \!="" \!=\"\"

  5. 5 Posted by jperreault on 06 Dec, 2012 07:23 PM

    jperreault's Avatar

    Note about above, the problems I have are in version 7.0.5

    In version 6.8 the search seems to work the way I expect it should.

  6. 6 Posted by Ryan Griffith on 06 Dec, 2012 07:28 PM

    Ryan Griffith's Avatar


    I ran a test on my local 7.0.5 instance and was able to return results for != "".

    Please see the attached screenshot for the terms/options I used.

    Let me know if you have any questions.


  7. Ryan Griffith closed this discussion on 11 Jan, 2013 01:25 PM.

Comments are currently closed for this discussion. You can start a new one.

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