Guide

Creating XSLT Functions

An XSLT function is a key function in C1 CMS. And as other types of CMS functions, an XSLT function is a logical unit that you can insert on a page, in markup of a page template or another function.

It serves three major purposes or the combination thereof in C1 CMS:

  • Content Reuse: XSLT functions make parts of content or functionality reusable within a single website and across multiple websites.
  • Dynamic Content Rendering: XSLT functions present dynamic content and allow its customization.
  • Integration: XSLT functions integrate external content or functionality by wrapping it up in format usable in C1 CMS.

As its name suggests, an XSLT function can transform anything that can be passed to it in XML format by using XSLT. It then outputs the transformed markup either as XHTML or XML. Internally, a XSLT function can use outputs of other CMS functions available in the system.

To create an XSLT function:

  1. In the Functions perspective, select XSLT Functions.
  2. Click Add XSLT Function on the toolbar.
  3. In the Add New XSLT Function window, specify its parameters:
    • Name: The name of the function
    • Namespace: The namespace it should belong to
    • Output type: The type of the function’s output: XHTML or XML
    • Copy from: Keep the option "(New XSLT function)" to create a new function, or select an existing XSLT function to copy from.
  4. Click OK.

Figure 1: Adding an XSLT function

The newly added function opens in the function editor.

Figure 2: XSLT function editor

You can also select a namespace in Step 1 and add a function to it. In this case, the namespace will be automatically entered in the Namespace field.

Please note that the name of the function serves as its identifier in the code, so it must only contain English letters (a-z, A-Z) and digits (0-9) and must start with a letter.

The functions that output XML are only available in the Select Function dialog invoked from the source code editor. XHTML-based functions are available both for the source code and visual content editors.