XSLT Overview

XSLT Overview

The XSL specification includes XSLT, XPath, and XSL-FO, OU Campus utilizes files with an XSL extention for tranformation. Gathered on this page are a few very basic XSL statements. As implementations have evolved the use of XSL elements has expanded to include more that the few found here as it is more typical of an implementation to use xsl:template, xsl:apply-template, and xsl:call-template, as well as conditionals and functions. For more information and details regarding the use of XSL, see:

Advanced XSL

Example PCF

The following is an example PCF file that uses the XSL mentioned on this page. Note that this example also makes use of the com.omniupdate style tagging, which is still supported, but the newer style of tagging is with the ouc: style node tags.

<document>
<title>Gallena University</title>
<content>
<!-- com.omniupdate.div label="content" group="Everyone" button="707" -->
<p>This is some example content.</p>
<!-- /com.omniupdate.div -->
</content>
</document>		

xsl:value-of

The xsl:value-of statement makes it easy to extract text-based content from a PCF file. This is a tag that can be used to access to simple text-based content. 

<xsl:value-of select="document/title" />		

This code would return the text string: Gallena University from the PCF example, which is a text node stored within the <title> element node.

xsl:copy-of

The xsl:copy-of pulls in the complete XML node of any node within the PCF. It also is a method to get HTML comments stored in a PCF to display. Since the xsl:value-of removes HTML comments found in content pulled from the PCF and just displays text, this was used in order to also grab the com.omniupdate style comment tagging.

<xsl:copy-of select="document/content/node()" />		

The above outputs the following:

<!-- com.omniupdate.div label="content" group="Everyone" button="707" -->
<p>This is some example content.</p>
<!-- /com.omniupdate.div -->		

Note that the comment tags, attributes and thier values, as well as the <p> tag, and the text node are all copied over.

xsl:choose

The xsl:choose is essentially the equivalent of an IF ELSE statement in other programming languages. This allows for strategic decisions to be made about how to display XSL output using the content obtained from the PCF.

<xsl:choose>
<xsl:when test="document/title">
<xsl:value-of select="document/title" />
</xsl:when>
<xsl:otherwise>
There was no title node in the PCF, so this message will be displayed instead.
</xsl:otherwise>
</xsl:choose>	

Other XSL conditionals and examples are provided in the Advanced XSL section.