User:Emetsger:StyleSheets:StyleTableRows
From DSpace Wiki
You could probably package up the XSL in a jar and use a resource:// to resolve the stylesheet. You could probably also run this as its own aspect.
[edit] theme sitemap
<map:transform src="tableclass.xsl"/>
[edit] <theme directory>/tableclass.xsl
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:i18n="http://apache.org/cocoon/i18n/2.1" xmlns:dri="http://di.tamu.edu/DRI/1.0/" xmlns:mets="http://www.loc.gov/METS/" xmlns:xlink="http://www.w3.org/TR/xlink/" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:dim="http://www.dspace.org/xmlns/dspace/dim" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mods="http://www.loc.gov/mods/v3" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="i18n dri mets xlink xsl dim xhtml mods dc"> <xsl:output indent="yes"/> <xsl:template match="node() | @*"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="//xhtml:tr[@class and not(contains(@class, 'odd')) and not(contains(@class, 'even'))]"> <xsl:variable name="parity"> <xsl:choose> <xsl:when test="position() mod 2 = 0">odd</xsl:when> <xsl:otherwise>even</xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:variable name="newclass" select="concat(@class, ' ', $parity)"/> <xsl:element name="tr"> <xsl:for-each select="@*"> <xsl:choose> <xsl:when test="name(.) = 'class'"> <xsl:attribute name="class"><xsl:value-of select="$newclass"/></xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:copy-of select="."/> </xsl:otherwise> </xsl:choose> </xsl:for-each> <xsl:copy-of select="node()"/> </xsl:element> </xsl:template> </xsl:stylesheet>
