Skip to main content

Office of Information Technology (OIT)

UT Arlington
OIT: Office of Information Technology

helpdesk@uta.edu ·  Work Order · 817-272-2208 · System Status

We are your IT partner!

Velocity

UT Arlington Velocity Examples

The .zip file XMLandVelocityExamples contains several Velocity examples (.vm file) and the corresponding XML files. The examples were implemented on the HR site. The following links point to the pages generated by the Velocity transformation:

HR - About Us 

HR - staff-hr-page

HR - job families-all-lst

HR - job-family-i-lst

TOC Page

Velocity Context

These examples make ample use of variables and tools available within Cascade Server's Velocity Context. Please refer to Hannon Hill's knowledgebase for more information: Velocity Tools.

$_contentRoot
JDOM element representing the full XML contents of the Block assigned to the Region to which your Velocity Format is applied.

$_XPathTool
XPath support allows selecting specific sections of the XML structure using XPath expressions.

Support for XPath statements allows users to query the JDOM XML structure using an XPath expression, similar to using an XPath expression in the "select" attribute of an XSL template.

$_SerializerTool
WYSIWYG fields have HTML-styled content with nested HTML tags. This structure needs to be serialized to make sure all nested tags are being formatted for document output. The Serializer Tool should also be used for special characters in plain text values.

The Serializer Tool can take any node in the XML hierarchy backed by JDOM and serialize it into its underlying XML, without having to output each node in the JDOM tree manually.

$_SortTool
Provides easy sorting functionality to Velocity Scripts.

The Sort Tool is modeled after the <xsl:sort/> directive and contains two methods: sort() and addSortCriterion().  The sort() method takes a list of JDOM Elements, which can be acquired using the XPath Tool, and sorts them based on the criteria specified using the addSortCriterion() method. The addSortCriterion() method takes 5 arguments: a selection string, language, data type, sort order, and case order.

$_DateTool
Provides convenience methods for dat comparisons and date formatting.

$_StringTool
Provides convenience methods for manipulating text data.

The String Tool contains two methods, substringBefore() and substringAfter(). For example, if one were to call the substringAfter() method with the arguments "/path/to/asset" and "path", the result would be "/to/asset".

Related Resources

Hannon Hill Velocity info: http://www.hannonhill.com/kb/Script-Formats/     (Technical – Velocity Resources) All features listed under “Velocity Tools” are only available with Cascade Server 6.2.x.

Hannon Hill Velocity Webinar

JDOM API: http://jdom.org/docs/apidocs/

JDOM Element: http://www.jdom.org/docs/apidocs/org/jdom/Element.html

Velocity User Guide: http://velocity.apache.org/engine/releases/velocity-1.5/user-guide.html

Velocity and XML: http://velocity.apache.org/engine/releases/velocity-1.5/developer-guide.html#velocity_and_xml

VTL (Velocity Template Language): http://velocity.apache.org/engine/releases/velocity-1.5/vtl-reference-guide.html

XPath: http://www.w3schools.com/XPath/xpath_syntax.asp