Browse Source

Clean up and formatting

pull/99/head
Adam Vessey 13 years ago
parent
commit
ccfc845464
  1. 190
      xsl/sparql_to_html.xsl

190
xsl/sparql_to_html.xsl

@ -1,12 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php"> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:s="http://www.w3.org/2001/sw/DataAccess/rf1/result" version="1.0" xmlns:php="http://php.net/xsl" exclude-result-prefixes="php">
<!-- Red and White XSLT --> <!-- Red and White XSLT -->
<xsl:variable name="BASEURL"> <xsl:variable name="BASEURL" select="$baseUrl"/>
<xsl:value-of select="$baseUrl"/> <xsl:variable name="PATH" select="$path"/>
</xsl:variable>
<xsl:variable name="PATH">
<xsl:value-of select="$path"/>
</xsl:variable>
<xsl:variable name="thisPid" select="$collectionPid"/> <xsl:variable name="thisPid" select="$collectionPid"/>
<xsl:variable name="size" select="20"/> <xsl:variable name="size" select="20"/>
<xsl:variable name="page" select="$hitPage"/> <xsl:variable name="page" select="$hitPage"/>
@ -14,141 +10,80 @@
<xsl:variable name="end" select="($start - 1) + number($size)"/> <xsl:variable name="end" select="($start - 1) + number($size)"/>
<xsl:variable name="cellsPerRow" select="4"/> <xsl:variable name="cellsPerRow" select="4"/>
<xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/> <xsl:variable name="count" select="count(s:sparql/s:results/s:result)"/>
<xsl:template match="/">
<xsl:template match="/">
<xsl:if test="$count>0"> <xsl:if test="$count>0">
<table cellpadding="3" cellspacing="3" width="90%"> <xsl:call-template name="render_pager"/>
<tr><td colspan="{$cellsPerRow}"> <table cellpadding="3" cellspacing="3" width="90%">
<!-- <div STYLE="text-align: center;">--> <xsl:apply-templates select="s:sparql/s:results"/>
<!-- start previous next --> </table><br clear="all" />
<div class="item-list"> <xsl:call-template name="render_pager"/>
<ul class="pager"> </xsl:if>
<xsl:choose> </xsl:template>
<xsl:when test="$end >= $count and $start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/>
of <xsl:value-of select="$count"/>&#160;<br />
</xsl:when>
<xsl:when test="$end >= $count">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/> <xsl:template match="s:sparql/s:results">
of <xsl:value-of select="$count"/>&#160;<br /> <xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() &lt;=$end]">
<li class="pager-previous"> <tr>
<a> <xsl:apply-templates select=". | following-sibling::s:result[position() &lt; $cellsPerRow]"/>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> </tr>
</xsl:attribute> </xsl:for-each>
&lt;Prev </xsl:template>
</a></li>
</xsl:when>
<xsl:when test="$start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-next">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/>
</xsl:attribute>
Next>
</a></li>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/>
</xsl:attribute>
&lt;Prev
</a>&#160;</li>
<li class="pager-next">
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/>
</xsl:attribute>
Next>
</a></li>
</xsl:otherwise>
</xsl:choose>
</ul>
</div>
<!-- end previous next-->
<br clear="all" />
</td></tr>
<!--<xsl:for-each select="/sparql/results/result[position()>=$start and position() &lt;=$end]"> <xsl:template name="render_pager">
<xsl:variable name='OBJECTURI' select="object/@uri"/> <!-- start previous next -->
<xsl:variable name='PID' select="substring-after($OBJECTURI,'/')"/>
<tr>
<td>
<img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN
</xsl:attribute>
</img>
<a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="title"/>
</xsl:attribute>
<xsl:value-of select="title"/>
</a>
</td>
</tr>
</xsl:for-each>-
-->
<xsl:apply-templates select="s:sparql/s:results"/>
</table><br clear="all" />
<!-- start previous next -->
<div class="item-list"> <div class="item-list">
<ul class="pager"> <ul class="pager">
<xsl:choose> <xsl:choose>
<xsl:when test="$end >= $count and $start = 1"> <xsl:when test="$end >= $count and $start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/> <xsl:value-of select="concat($start, '-', $count, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
</xsl:when> </xsl:when>
<xsl:when test="$end >= $count"> <xsl:when test="$end >= $count">
<xsl:value-of select="concat($start, '-', $count, ' of ', $count, '&#160;')"/><br />
<xsl:value-of select="$start"/>-<xsl:value-of select="$count"/>
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a></li> </a>
</li>
</xsl:when> </xsl:when>
<xsl:when test="$start = 1"> <xsl:when test="$start = 1">
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/> <xsl:value-of select="concat($start, '-', $end, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a></li> </a>
</li>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="$start"/>-<xsl:value-of select="$end"/> <xsl:value-of select="concat($start, '-', $end, ' of ', $count, '&#160;')"/><br />
of <xsl:value-of select="$count"/>&#160;<br />
<li class="pager-previous"> <li class="pager-previous">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page - 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page - 1)"/>
</xsl:attribute> </xsl:attribute>
&lt;Prev &lt;Prev
</a>&#160;</li> </a>&#160;
</li>
<li class="pager-next"> <li class="pager-next">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$thisPid"/>/-/Collection/<xsl:value-of select="$page + 1"/> <xsl:attribute name="href">
<xsl:value-of select="concat($BASEURL, '/fedora/repository/', $thisPid, '/-/Collection/', $page + 1)"/>
</xsl:attribute> </xsl:attribute>
Next> Next>
</a></li> </a>
</li>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</ul> </ul>
</div> </div>
<!-- end previous next--> <!-- end previous next-->
</xsl:if>
</xsl:template>
<xsl:template match="s:sparql/s:results">
<xsl:for-each select="s:result[position() mod $cellsPerRow = 1 and position()>=$start and position() &lt;=$end]">
<tr>
<xsl:apply-templates select=". | following-sibling::s:result[position() &lt; $cellsPerRow]"/>
</tr>
</xsl:for-each>
</xsl:template> </xsl:template>
<xsl:template match="s:result"> <xsl:template match="s:result">
<xsl:variable name='OBJECTURI' select="s:object/@uri"/> <xsl:variable name='OBJECTURI' select="s:object/@uri"/>
<xsl:variable name='CONTENTURI' select="s:content/@uri"/> <xsl:variable name='CONTENTURI' select="s:content/@uri"/>
@ -160,48 +95,46 @@
<xsl:with-param name="from" select="'_'"/> <xsl:with-param name="from" select="'_'"/>
<xsl:with-param name="to" select="' '"/> <xsl:with-param name="to" select="' '"/>
</xsl:call-template> </xsl:call-template>
</xsl:variable>
<xsl:variable name="cleanTitle">
<xsl:value-of select="php:functionString('fedora_repository_urlencode_string', $newTitle)"/>
</xsl:variable> </xsl:variable>
<xsl:variable name="cleanTitle" select="php:functionString('fedora_repository_urlencode_string', $newTitle)"/>
<xsl:variable name="linkUrl"> <xsl:variable name="linkUrl">
<xsl:choose> <xsl:choose>
<xsl:when test="($CONTENTMODEL='islandora:collectionCModel')"> <xsl:when test="($CONTENTMODEL='islandora:collectionCModel')">
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="'collection'"/> <xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/-/collection')"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<!--the below is an example of going straight to a datastream instead of the details page. <!--the below is an example of going straight to a datastream instead of the details page.
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>--> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/OBJ/<xsl:value-of select="s:title"/>-->
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/> <xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID)"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
<xsl:value-of select="s:content"/> <xsl:value-of select="s:content"/>
</xsl:variable> </xsl:variable>
<td valign="top" width="25%"> <td valign="top" width="25%">
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href">
<xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<img> <img>
<xsl:attribute name="src"><xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:value-of select="$PID"/>/TN <xsl:attribute name="src"><xsl:value-of select="concat($BASEURL, '/fedora/repository/', $PID, '/TN')"/></xsl:attribute>
</xsl:attribute> <xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/></xsl:attribute>
<xsl:attribute name="alt"><xsl:value-of select="$newTitle" disable-output-escaping="yes"/> </img>
</xsl:attribute> </a><br clear="all" />
</img> </a> <br clear="all" />
<a> <a>
<xsl:attribute name="href"><xsl:value-of select="$linkUrl"/> <xsl:attribute name="href"><xsl:value-of select="$linkUrl"/>
</xsl:attribute> </xsl:attribute>
<xsl:value-of select="$newTitle" disable-output-escaping="yes" /> <xsl:value-of select="$newTitle" disable-output-escaping="yes" />
</a> </a>
<!-- example of a url that would drill down to the details page if the url above went directly to a datastream <!-- example of a url that would drill down to the details page if the url above went directly to a datastream
<xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')"> <xsl:if test="($CONTENTMODEL!='islandora:collectionCModel')">
<br />[[ <a> <br />[[ <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/> <xsl:value-of select="$BASEURL"/>/fedora/repository/<xsl:copy-of select="$PID"/>/-/<xsl:value-of select="$cleanTitle"/>
</xsl:attribute> </xsl:attribute>
DETAILS DETAILS
</a> ]] </a> ]]
</xsl:if>--> </xsl:if>-->
</td> </td>
<xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)"> <xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)">
@ -210,6 +143,7 @@ DETAILS
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="FillerCells"> <xsl:template name="FillerCells">
<xsl:param name="cellCount"/> <xsl:param name="cellCount"/>
<td>&#160;</td> <td>&#160;</td>
@ -219,6 +153,7 @@ DETAILS
</xsl:call-template> </xsl:call-template>
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template name="replace-string"> <xsl:template name="replace-string">
<xsl:param name="text"/> <xsl:param name="text"/>
<xsl:param name="from"/> <xsl:param name="from"/>
@ -245,4 +180,3 @@ DETAILS
</xsl:choose> </xsl:choose>
</xsl:template> </xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

Loading…
Cancel
Save