Guide

Test Your Knowledge

Task: Create an XSLT Function

  1. Add an XSLT function.
  2. Specify its name as “ShowCurrentDate”.
  3. Specify its namespace as “Demo”.
  4. In the function editor, on the Settings tab, write its description.
  5. Save the function.
  6. In the Functions perspective, expand All Functions, select Demo and click Generate Documentation on the toolbar.
  7. Make sure the function has the description.

Task: Add a Function Call

  1. Add a function call to Composite.Utils.Date.Now.
  2. Specify its local name as “CurrentDate”.
  3. Save the function.

Task: Edit the Template

  1. On the Template tab, remove the default contents between the <body> and </body> tags.
  2. Use the called Composite.Utils.Date.Now function’s output in the markup by referring to it by its local name “CurrentDate”.
  3. Save the function.
  4. Preview the function and make sure that the current date appears in the input and output panes.

Task: Add an Input Parameter

  1. Add the Boolean parameter “LongDate”.
  2. Edit its default value.
  3. Add Composite.Constant.Boolean and set its value to “True”.
  4. Save the function.

Task: Use an Extension Function

  1. Add a call to the extension function Xslt.Extensions.DateFormating.
  2. On the Template tab, register the ‘xsl:df = "#dateExtensions"’ namespace.
  3. Use the ‘df: LongDateFormat’ extension function on the function call’s output in the template.
  4. Save the function.
  5. Preview the output of the function and make sure the long date appears now.

Task: Use XSLT to Switch between Two Date Formats

  1. Use the XSLT syntax to have two branches for the current date’s format (<xsl:choose> etc).
  2. Use the input parameter “LongDate” and its value (‘true’, ‘false’) to specify each branch of the current date’s format (<xsl:when test=”...”> etc).
  3. For the “LongDate” set to ‘true’ use the ‘df:LongDateFormat’ extension function on the “CurrentDate” function’s output
  4. For the “LongDate” set to ‘false’ use the ‘df:ShortDateFormat’ extension function on the “CurrentDate” function’s output.
  5. Save the function.
  6. Insert the function on a page in the Content perspective.
  7. Set its LongDate parameter to ‘false’.
  8. Preview the page and make sure that the date is displayed in short format.