...
Code Block |
---|
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Declaration of parameters -->
<!-- if you want to use a Sakai value or a passed in parameter from the -->
<!-- query string, you should state it here -->
<!-- The id parameter from the query string -->
<xsl:param name="id"/>
<!-- a number we can switch on to display different content for each page -->
<xsl:param name="pageNumber"/>
<!-- if passed, the created variable will be a key to a single blog Entry -->
<xsl:param name="created"/>
<!-- Declare output method -->
<xsl:output method="html"/>
<!-- Main Template outputs our HTML page -->
<xsl:template match="/">
<html>
<head><title><xsl:text>My Blog</xsl:text></title></head>
<body>
<div>
<img>
<xsl:attribute name="src">
<xsl:value-of select="/ospiPresentation/presentationFiles/myLogo/artifact/fileArtifact/uri"/>
</xsl:attribute>
<xsl:attribute name="alt">My Institutions Logo</xsl:attribute>
<xsl:attribute name="style">float: right; padding: 1em</xsl:attribute>
</img>
<h1>My Blog</h1>
</div>
<!-- uncomment this if you want to see these vaiables printed ugly style on top of the page
<xsl:text>id:</xsl:text>
<xsl:value-of select="$id"/>
<br/>
<xsl:text>pageNumber:</xsl:text>
<xsl:value-of select="$pageNumber"/>
<br/>
-->
<!-- a little menu to navigate -->
<div id="menu" style="width: 100%; padding: 1em; margin: 1em 0; border-bottom: solid 1px black">
<xsl:call-template name="menuLink">
<xsl:with-param name="pageNumber"></xsl:with-param>
<xsl:with-param name="text">Home</xsl:with-param>
</xsl:call-template> |
<xsl:call-template name="menuLink">
<xsl:with-param name="pageNumber">2</xsl:with-param>
<xsl:with-param name="text">All Entries</xsl:with-param>
</xsl:call-template>
</div>
<!-- a switch to select content for this page based on the value of pageNumber -->
<div>
<xsl:choose>
<xsl:when test="$pageNumber=2">
<h3>All Entries</h3>
<ul>
<xsl:for-each select="/ospiPresentation/blogEntry/artifact">
<xsl:sort select="./metaData/repositoryNode/created" order="descending"/>
<li>
<a>
<xsl:attribute name="href">
<xsl:text disable-output-escaping="yes">viewPresentation.osp?id=</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text disable-output-escaping="yes">&pageNumber=3&created=</xsl:text>
<xsl:value-of select="./metaData/repositoryNode/created"/>
</xsl:attribute>
<xsl:value-of select="./metaData/displayName"/> -
<xsl:value-of select="./metaData/repositoryNode/created"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:when>
<xsl:when test="$pageNumber=3">
<xsl:for-each select="/ospiPresentation/blogEntry/artifact[metaData/repositoryNode/created=$created]">
<div style="border: solid 1px black; padding: 1em; margin: 1em 1em 2em 2em">
<h3><xsl:value-of select="./metaData/displayName"/></h3>
<h4><xsl:value-of select="./metaData/repositoryNode/created"/></h4>
<xsl:value-of select="./structuredData/blogEntry/entryBody" disable-output-escaping="yes"/>
</div>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<xsl:for-each select="/ospiPresentation/blogEntry/artifact[position() < 5]">
<xsl:sort select="./metaData/repositoryNode/created" order="descending"/>
<div style="border: solid 1px black; padding: 1em; margin: 1em 1em 2em 2em">
<h3><xsl:value-of select="./metaData/displayName"/></h3>
<h4><xsl:value-of select="./metaData/repositoryNode/created"/></h4>
<xsl:value-of select="./structuredData/blogEntry/entryBody" disable-output-escaping="yes"/>
</div>
</xsl:for-each>
</xsl:otherwise>
</xsl:choose>
</div>
</body>
</html>
</xsl:template>
<!-- a named template to display links correctly -->
<xsl:template name="menuLink">
<xsl:param name="pageNumber"/>
<xsl:param name="text"/>
<span style="padding: 0 2em;">
<a>
<xsl:attribute name="href">
<xsl:text disable-output-escaping="yes">viewPresentation.osp?id=</xsl:text>
<xsl:value-of select="$id"/>
<xsl:text disable-output-escaping="yes">&pageNumber=</xsl:text>
<xsl:value-of select="$pageNumber"/>
</xsl:attribute>
<xsl:value-of select="$text"/>
</a>
</span>
</xsl:template>
</xsl:stylesheet>
|