Skip to main content
Windward

How to use XPath functions in Windward document templates

Overview

Windward offers the ability to work with XML data files using XPath. XPath offers the ability to make use of various functions that can allow the user to manipulate the XML data in many unique and complex ways. Windward passes all XPath to an XPath parser behind the scenes. Most functions work properly.

Resolution

There are two examples attached to this post.

The first example is a master template that gives examples of using all XPath functions that Windward supports in Windward tags. This document is titled "XPath_Unit_Test.zip". Here you will find all basic XPath functions and simple examples of each.

The second example makes use of several XPath functions in conjunction to process a complex string manipulate on an XPath node. It will transform a word in all CAPS to only have the first letter capitalized and then all following letters transformed to lower case. The tag is listed below:

<wr:out select="concat(substring(/OfferData/MetaData/Name,1,1),translate(substring-after(/OfferData/MetaData/Name,substring(/OfferData/MetaData/Name,1,1)),&apos;ABCDEFGHIJKLMNOPQRSTUVWXYZ&apos;, &apos;abcdefghijklmnopqrstuvwxyz&apos;))" datasource="car"/>

The concat function was used in conjunction with the substring function. It first takes the data in the XML node and concatenates the first letter with the result of the translate and substring-after functions which transposes all remaining letters into lower case. The end result transforms NAME into Name.

  • Was this article helpful?