Modern Campus Catalog Emblem Modern Campus CMS Emblem Modern Campus Curriculum Emblem Modern Campus Involve Emblem Modern Campus Lifelong Learning Extended Education Emblem Modern Campus Message Emblem Modern Campus Navigate Emblem Modern Campus Schedule Emblem Modern Campus Virtual Tours & Maps Emblem Modern Campus Lifelong Learning Workforce and Community Emblem Site Menu Open Site Menu Close

XSL Reference Guide

XSL (eXtensible Stylesheet Language) is a templating language used to transform, translate, or render XML documents. Within Modern Campus CMS, the contents of PCF files can be transformed into multiple data formats using XSLT, including but not limited to HTML, PHP Code, JSON, Text, JavaScript, CSS, and PDF (using XSL:FO).

ElementDescriptionAttributesExample
xsl:stylesheetDefines the root node of an XSL file. It appears after the prolog and must contain at least one namespace declaration.
  • version (required): defines the XSLT version utilized.
  • xmlns: [namespace] (required): defines the XSLT namespace utilized.
  • exclude-result-prefixes: specifies any namespaces which should not be copied when output.
<xsl:stylesheet version="3.0"
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns:xs="http://www.w3.org/2001/XMLSchema"
		xmlns:ou="http://omniupdate.com/XSL/Variables"
		xmlns:ouc="http://omniupdate.com/XSL/Variables"
		exclude-result-prefixes="xsl xs ou ouc">
</xsl:stylesheet>
xsl:importImports the XSLT of another stylesheet into the current one. Elements within the included stylesheet have less precedence than those defined in the current stylesheet.
  • href (required): defines the URL of a stylesheet to be imported.
<xsl:import href="common.xsl"/>
xsl:outputSpecifies the output format of the document resulting from the XSL transformation.
  • method: defines the output format. Options include xml, html, and text. If this attribute is missing, the default is xml.
  • version: specifies the version of XML to be output.
  • encoding: specifies the encoding attribute on the output.
  • indent: specifies whether the output should include indentations based upon a hierarchical structure.
  • include-content-type: specifies whether a meta tag should be inserted into the head element. Only applicable for HTML output method using XSLT 2.0 and above.
  • omit-xml-declaration: specifies whether the XML declaration should be removed from the output. Options are yes and no. If this attribute is missing, the default value is no.
<xsl:output method="html" version="5.0" indent="no" encoding="UTF-8" include-content-type="no"/>
xsl:functionCreates your own XSL stylesheet functions, which are then called upon using an XPath expression. Any functions defined in this way need to begin with a namespace prefix which is unique to user-generated functions.
  • name (required): unique identifier for this function which must begin with a namespace prefix unique to user-generated functions.
  • as: defines the type of value to be returned when the function is invoked.
  • override-extension-function: specifies whether this user-generated function should override other functions of the same name. Options are yes or no. If this attribute is missing, the default value is yes.
<xsl:function name="ou:ssi">
	<xsl:param name="fullpath"/>
	<xsl:processing-instruction name="php"> include($_SERVER['DOCUMENT_ROOT'] . "<xsl:value-of select="$fullpath" />"); ?</xsl:processing-instruction>
</xsl:function>
xsl:templateDefines processing instructions for a particular XML node or source element. xsl:template can be invoked by name using xsl:call-template or by pattern using xsl:apply-templates.
  • name (required): unique identifier for this template.
  • match (required if no name attribute is present): pattern identifier for this template.
  • mode: specifies the mode which must be matched in an xsl:apply-templates element in order for this template to be invoked
<xsl:template name="common-header">
	<xsl:copy-of select="ou:include-file('/_resources/includes/header.inc')"/>
</xsl:template>
<xsl:template match="table" mode="maincontent">
	<xsl:variable name="contents"><xsl:value-of select="./node()"/></xsl:variable>
</xsl:template>
xsl:call-templateInvokes an xsl:template by name.
  • name (required): unique identifier which must match the name attribute in an xsl:template.
  • xsl:with-param: a way to pass params to the called template
<xsl:call-template name="common-header">
	<xsl:with-param name="path">/_resources/includes/header.inc</xsl:with-param>
</xsl:call-template>
xsl:apply-templatesInvokes an xsl:template by pattern.
  • select (required): defines the patten which matches to an xsl:template.
  • mode: if included, only invokes an xsl:template with a matching mode.
<xsl:apply-templates select="table" mode="maincontent" />
xsl:copyAlso known as a "shallow copy." Copies and inserts a node. It does not copy any child nodes, descendants, or attributes of the original node.
  • copy-namespace: specifies whether the namespace should be copied. Options are yes or no. If this attribute is missing, the default value is yes.
<xsl:copy>
	<xsl:apply-templates select="ouc:editor" />
</xsl:copy>
xsl:paramDeclares a parameter. In this case, the value assigned to the parameter is the default and can be changed when used within an xsl:call-template or xsl:apply-templates.
  • name (required): unique identifier for this parameter.
  • select: an expression which defines the value of the parameter.
  • required: specifies whether the parameter is mandatory. Options are yes or no. If this attribute is missing, the default value is no.
  • as: the return type of the parameter.
<xsl:param name="href" required="yes" as="xs:string"/>
<xsl:param name="serverType">php</xsl:param>
xsl:variableDeclares a variable which is a constant value. If declared immediately within the xsl:stylesheet node, this is a global variablename (required): unique identifier for this variable.
  • select: an expression which defines the value of the variable.
  • as: the return type of the variable.
<xsl:variable name="nav-file" select="'_nav.inc'" />
<xsl:variable name="col-count">
	<xsl:choose>
		<xsl:when test="$row_col_count = 4"><xsl:value-of select="$four-column-class" /></xsl:when>
		<xsl:when test="$row_col_count = 3"><xsl:value-of select="$three-column-class" /></xsl:when>
		<xsl:otherwise><xsl:value-of select="$two-column-class" /></xsl:otherwise> 
	</xsl:choose>
</xsl:variable>
xsl:copy-ofAlso known as a "deep copy." Copies and inserts a node and all its descendents.
  • select (required): defines the value or nodes to be copied.
  • copy-namespace: specifies whether the namespace should be copied. Options are yes or no. If this attribute is missing, the default value is yes.
<xsl:copy-of select="ouc:div[@label='related-content']/(attribute()|ouc:editor)"/>
xsl:value-ofCopies the text value of a node resulting in a string output.
  • select (required): defines the value or node to be copied.
  • disable-output-escaping: specifies whether special characters should be XML escaped. Options are yes or no. If this attribute is missing, the default value is no.
<xsl:value-of select="tbody/tr[2]/td[1]" />
xsl:ifDefines a conditional test and an action to take in the event the test returns as true.
  • test (required): defines the boolean condition to be tested. Output is true or false.
<xsl:if test="@required = 'true'">
	<xsl:attribute name="required"></xsl:attribute>
</xsl:if>
xsl:chooseA parent element which wraps any number of xsl:when elements and a single, optional xsl:otherwise element. This element wraps a set of conditional options which are tested in order of appearance.This element has no attributes.
<xsl:choose>
	<xsl:when test="output/submit_text/text() != '">
		<xsl:value-of select="output/submit_text/text()" />
	</xsl:when>
	<xsl:otherwise>
		Submit
	</xsl:otherwise>
</xsl:choose>
xsl:whenA child element of xsl:choose. This element defines a conditional test and an action to take in the event the test returns as true. An xsl:choose element may have an unlimited number of xsl:when elements, but the first xsl:when element to return true terminates the xsl:choose operation.
  • test (required): defines the boolean condition to be tested. Output is true or false.
<xsl:when test="output/submit_text/text() != '">
<xsl:value-of select="output/submit_text/text()" />
</xsl:when>
xsl:otherwiseAn optional child element of xsl:choose. This element should be declared last within the xsl:choose and defines the action to take in the event all previously stated xsl:when elements returned false.This element has no attributes.
<xsl:otherwise>
	Submit
</xsl:otherwise>
xsl:for-eachSpecifies an XPath expression which may apply to multiple XML nodes and defines an action to take upon each one.
  • select (required): XPath expression identifying a specific node or value within an XML file.
<xsl:for-each select="tbody/tr[3]/td[1]/descendant::p">
	<p class="text"><xsl:value-of select="node()"/></p>
</xsl:for-each>
xsl:elementDefines a literal element to be inserted during the transformation.
  • name
(required): defines the name of the element that will be created.
<xsl:element name="test">
<xsl:text>This is a test document</xsl:text>
</xsl:element>

Output:

<test>This is a test document</test>
xsl:textDefines literal text to be inserted during the transformation.
  • disable-output-escaping: specifies whether special characters should be XML escaped. Options are yes and no. If this attribute is missing, the default value is no.
<xsl:text disable-output-escaping="yes">&lt;</xsl:text>html lang="en"<xsl:text disable-output-escaping="yes">&gt;</xsl:text>

Output:

<html lang="en">
xsl:commentOutputs an HTML comment node.This element has no attributes.
<xsl:comment>Comment goes here</xsl:comment>

By continuing to use this site, you agree to the storing of first- and third-party cookies on your device to enhance site navigation; analyze site, product, and service usage; and assist in our marketing and promotional efforts. Cookie Policy