diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-03-01 19:17:32 +0000 |
commit | e38d2351b83fa65c66ccde443777647ef5cb6cff (patch) | |
tree | 1897fc20e9f73a81c520a5b9f76f8ed042124883 /xslt/report-templates | |
download | tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.tar.gz tellico-e38d2351b83fa65c66ccde443777647ef5cb6cff.zip |
Added KDE3 version of Tellico
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/tellico@1097620 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'xslt/report-templates')
-rw-r--r-- | xslt/report-templates/Column_View.xsl | 310 | ||||
-rw-r--r-- | xslt/report-templates/Group_Summary.xsl | 323 | ||||
-rw-r--r-- | xslt/report-templates/Group_View.xsl | 284 | ||||
-rw-r--r-- | xslt/report-templates/Image_List.xsl | 250 | ||||
-rw-r--r-- | xslt/report-templates/Loan_View.xsl | 201 | ||||
-rw-r--r-- | xslt/report-templates/Makefile.am | 21 | ||||
-rw-r--r-- | xslt/report-templates/Title_Listing_(Horizontal).xsl | 146 | ||||
-rw-r--r-- | xslt/report-templates/Title_Listing_(Vertical).xsl | 156 | ||||
-rw-r--r-- | xslt/report-templates/Tri-Column.xsl | 234 |
9 files changed, 1925 insertions, 0 deletions
diff --git a/xslt/report-templates/Column_View.xsl b/xslt/report-templates/Column_View.xsl new file mode 100644 index 0000000..3b007fe --- /dev/null +++ b/xslt/report-templates/Column_View.xsl @@ -0,0 +1,310 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:str="http://exslt.org/strings" + xmlns:dyn="http://exslt.org/dynamic" + extension-element-prefixes="str dyn" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Column View Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- To choose which fields of each entry are printed, change the + string to a space separated list of field names. To know what + fields are available, check the Tellico data file for <field> + elements. --> +<xsl:param name="column-names" select="'title'"/> +<xsl:variable name="columns" select="str:tokenize($column-names)"/> + +<!-- set the maximum image size --> +<xsl:param name="image-height" select="'100'"/> +<xsl:param name="image-width" select="'100'"/> + +<!-- Up to three fields may be used for sorting. --> +<xsl:param name="sort-name1" select="'title'"/> +<xsl:param name="sort-name2" select="''"/> +<xsl:param name="sort-name3" select="''"/> +<!-- This is the title just beside the collection name. It will + automatically list which fields are used for sorting. --> +<xsl:param name="sort-title" select="''"/> +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data files are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<!-- In case the field has multiple values, only sort by first one --> +<xsl:variable name="sort1"> + <xsl:if test="string-length($sort-name1) > 0"> + <xsl:value-of select="concat('.//tc:', $sort-name1, '[1]')"/> + </xsl:if> +</xsl:variable> + +<xsl:variable name="sort1-type"> + <xsl:choose> + <xsl:when test=".//tc:field[@name=$sort-name1]/@type = 6">number</xsl:when> + <xsl:otherwise>text</xsl:otherwise> + </xsl:choose> +</xsl:variable> + +<xsl:variable name="sort2"> + <xsl:if test="string-length($sort-name2) > 0"> + <xsl:value-of select="concat('.//tc:', $sort-name2, '[1]')"/> + </xsl:if> +</xsl:variable> + +<xsl:variable name="sort2-type"> + <xsl:choose> + <xsl:when test=".//tc:field[@name=$sort-name2]/@type = 6">number</xsl:when> + <xsl:otherwise>text</xsl:otherwise> + </xsl:choose> +</xsl:variable> + +<xsl:variable name="sort3"> + <xsl:if test="string-length($sort-name3) > 0"> + <xsl:value-of select="concat('.//tc:', $sort-name3, '[1]')"/> + </xsl:if> +</xsl:variable> + +<xsl:variable name="sort3-type"> + <xsl:choose> + <xsl:when test=".//tc:field[@name=$sort-name3]/@type = 6">number</xsl:when> + <xsl:otherwise>text</xsl:otherwise> + </xsl:choose> +</xsl:variable> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + <xsl:if test="count($columns) > 3"> + font-size: 80%; + </xsl:if> + background-color: #fff; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + } + th { + color: #000; + background-color: #ccc; + border: 1px solid #999; + font-size: 1.1em; + font-weight: bold; + padding-left: 4px; + padding-right: 4px; + } + tr.r0 { + } + tr.r1 { + background-color: #eee; + } + td.field { + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-right: 5px; + border: 1px solid #eee; + text-align: left; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <table> + <!-- always print headers --> + <thead> + <tr> + <xsl:variable name="fields" select="tc:fields"/> + <xsl:for-each select="$columns"> + <th> + <xsl:call-template name="field-title"> + <xsl:with-param name="fields" select="$fields"/> + <xsl:with-param name="name" select="."/> + </xsl:call-template> + </th> + </xsl:for-each> + </tr> + </thead> + + <tbody> + <xsl:for-each select="tc:entry"> + <xsl:sort lang="$lang" select="dyn:evaluate($sort1)" data-type="{$sort1-type}"/> + <xsl:sort lang="$lang" select="dyn:evaluate($sort2)" data-type="{$sort2-type}"/> + <xsl:sort lang="$lang" select="dyn:evaluate($sort3)" data-type="{$sort3-type}"/> + <tr class="r{position() mod 2}"> + <xsl:apply-templates select="."/> + </tr> + </xsl:for-each> + </tbody> + </table> +</xsl:template> + +<xsl:template name="field-title"> + <xsl:param name="fields"/> + <xsl:param name="name"/> + <!-- remove namespace portion of qname --> + <xsl:variable name="name-tokens" select="str:tokenize($name, ':')"/> + <!-- the header is the title attribute of the field node whose + name equals the column name --> + <xsl:value-of select="$fields/tc:field[@name = $name-tokens[last()]]/@title"/> +</xsl:template> + +<xsl:template match="tc:entry"> + <!-- stick all the descendants into a variable --> + <xsl:variable name="current" select="descendant::*"/> + <xsl:variable name="entry" select="."/> + + <xsl:for-each select="$columns"> + <xsl:variable name="column" select="."/> + + <!-- find all descendants whose name matches the column name --> + <xsl:variable name="numvalues" select="count($current[local-name() = $column])"/> + <!-- if the field node exists, output its value, otherwise put in a space --> + <td class="field"> + <xsl:choose> + <!-- when there is at least one value... --> + <xsl:when test="$numvalues > 1"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <xsl:when test="$numvalues = 1"> + <xsl:for-each select="$current[local-name() = $column]"> + + <xsl:variable name="field" select="key('fieldsByName', $column)"/> + <xsl:choose> + + <!-- boolean and number values --> + <xsl:when test="$field/@type=4 or $field/@type=6"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <!-- next, check for images --> + <xsl:when test="$field/@type=10"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="concat($imgdir, .)"/> + </xsl:attribute> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="$image-width"/> + <xsl:with-param name="limit-height" select="$image-height"/> + <xsl:with-param name="image" select="key('imagesById', .)"/> + </xsl:call-template> + </img> + </xsl:when> + + <!-- if it's a date, format with hyphens --> + <xsl:when test="$field/@type=12"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <!-- handle URL here, so no link created --> + <xsl:when test="$field/@type=7"> + <xsl:value-of select="."/> + </xsl:when> + + <!-- finally, it's just a regular value --> + <xsl:otherwise> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:otherwise> + + </xsl:choose> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> + </xsl:choose> + </td> + </xsl:for-each> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Group_Summary.xsl b/xslt/report-templates/Group_Summary.xsl new file mode 100644 index 0000000..9058f78 --- /dev/null +++ b/xslt/report-templates/Group_Summary.xsl @@ -0,0 +1,323 @@ +<?xml version="1.0"?> +<!-- WARNING: Tellico uses tc as the internal namespace declaration, and it must be identical here!! --> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:exsl="http://exslt.org/common" + xmlns:dyn="http://exslt.org/dynamic" + extension-element-prefixes="exsl dyn" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Collection Summary Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:variable name="limit" select="5"/> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + color: #000; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + div.field { + margin-left: auto; + margin-right: auto; + margin-bottom: 20px; + width: 750px; + background-color: #ddd; + border: solid 1px #999; + overflow: auto; + padding: 0px 0px 0px 0px; + } + h2 { + font-size: 125%; + border-bottom: solid 1px #999; + text-align: center; + margin-top: 5px; + margin-bottom: 0px; + } + h3 { + font-size: 0.9em; + color: #666; + text-align: right; + padding-right: 4px; + margin-top: -1.1em; + margin-bottom: 0px; + } + h4 { + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + padding: 10px 0px 10px 0px; + } + div.row { + margin: 0px 0px 0px 0px; + padding: 0px 0px 0px 0px; + border: solid 1px transparent; + clear: left; + overflow: auto; + line-height: 120%; + } + div.group { + text-align: left; + margin: 0px 0px 0px 0px; + padding: 0px 10px 0px 4px; + float: left; + } + span.bar { + width: 590px; + margin: 1px 2px 1px 150px; + position: absolute; + float: left; + border-left: solid 5px #ddd; /* padding of a sort */ + } + span.bar span { + border-top: outset 1px #669; + border-right: outset 2px #003; + border-bottom: outset 2px #003; + border-left: outset 2px #669; + float: left; + position: absolute; + background-color: #336; + color: white; + padding-right: 4px; + padding-bottom: 2px; + font-size: 0.9em; + line-height: 0.9em; + text-align: right; + font-style: italic; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + <i18n>: Group Summary</i18n> + </h1> + + <xsl:variable name="coll" select="."/> + + <table> + <tbody> + <tr> + <th><i18n>Total number of fields:</i18n></th> + <th style="padding-right: 50px; color: #006;"> + <xsl:value-of select="count(tc:fields/tc:field)"/> + </th> + <th><i18n>Total number of entries:</i18n></th> + <th style="color:#006;"> + <xsl:value-of select="count(tc:entry)"/> + </th> + </tr> + </tbody> + </table> + <!-- grouping flag is second bit from right --> + <xsl:for-each select="tc:fields/tc:field[boolean(floor(@flags div 2) mod 2)]"> + <xsl:call-template name="output-group"> + <xsl:with-param name="coll" select="$coll"/> + <xsl:with-param name="fieldname" select="@name"/> + </xsl:call-template> + </xsl:for-each> + + <!-- + <h4><a href="http://www.periapsis.org/tellico/"><i18n>Generated by Tellico</i18n></a></h4> +--> +</xsl:template> + +<xsl:template name="output-group"> + <xsl:param name="coll"/> + <xsl:param name="fieldname"/> + + <xsl:variable name="str"> + <xsl:choose> + <xsl:when test="boolean(floor(key('fieldsByName', $fieldname)/@flags mod 2))"> + <xsl:choose> + <xsl:when test="key('fieldsByName', $fieldname)/@type=8"> + <xsl:value-of select="concat('$coll/tc:entry/tc:',$fieldname,'s/tc:',$fieldname,'/tc:column[1]')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('$coll/tc:entry/tc:',$fieldname,'s/tc:',$fieldname)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('$coll/tc:entry/tc:',$fieldname)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:variable name="values" select="dyn:evaluate($str)"/> + + <xsl:variable name="listing"> + <xsl:for-each select="$values[not(. = preceding::*)]"> + <!-- speed sorting by ignoring groups with a count of 1 --> + <xsl:variable name="c" select="count($values[. = current()])"/> + <xsl:if test="$c > 1"> + <group> + <xsl:attribute name="name"> + <xsl:call-template name="text-value"/> + </xsl:attribute> + <xsl:attribute name="count"> + <xsl:value-of select="$c"/> + </xsl:attribute> + </group> + </xsl:if> + </xsl:for-each> + </xsl:variable> + + <xsl:variable name="groups" select="exsl:node-set($listing)/group"/> + <xsl:variable name="total" select="count($groups)"/> + + <xsl:variable name="max"> + <xsl:call-template name="max-count"> + <xsl:with-param name="nodes" select="$groups"/> + </xsl:call-template> + </xsl:variable> + + <xsl:if test="$total > 2"> + + <div class="field"> + <h2> + <xsl:value-of select="key('fieldsByName', $fieldname)/@title"/> + </h2> + + <xsl:for-each select="$groups"> + <xsl:sort lang="$lang" select="@count" data-type="number" order="descending" /> + <xsl:sort lang="$lang" select="@name"/> + <xsl:if test="position() <= $limit"> + <div class="row"> + <div class="group"> + <xsl:value-of select="@name"/> + </div> + <span class="bar"> + <span> + <xsl:attribute name="style"> + <xsl:text>padding-left:</xsl:text> + <!-- the 540 is rather arbitrarily dependent on font-size, seem to work --> + <xsl:value-of select="floor(540 * @count div $max)"/> + <xsl:text>px;</xsl:text> + </xsl:attribute> + (<xsl:value-of select="@count"/>) + </span> + </span> + </div> + </xsl:if> + </xsl:for-each> + + <h3> + <i18n>Distinct values: </i18n><xsl:value-of select="$total"/> + </h3> + </div> + + </xsl:if> +</xsl:template> + +<xsl:template name="max-count"> + <xsl:param name="nodes" select="/.."/> + <xsl:param name="max"/> + + <xsl:variable name="count" select="count($nodes)"/> + <xsl:variable name="aNode" select="$nodes[ceiling($count div 2)]"/> + + <xsl:choose> + <xsl:when test="$count = 0"> + <xsl:value-of select="number($max)"/> + </xsl:when> + + <xsl:otherwise> + <xsl:call-template name="max-count"> + + <xsl:with-param name="nodes" select="$nodes[not(@count <= number($aNode/@count))]"/> + <xsl:with-param name="max"> + <xsl:choose> + <xsl:when test="not($max) or $aNode/@count > $max"> + <xsl:value-of select="$aNode/@count"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$max"/> + </xsl:otherwise> + </xsl:choose> + </xsl:with-param> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template name="text-value"> + <xsl:choose> + <xsl:when test="text()"> + <xsl:value-of select="text()"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="..//tc:column[1]"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Group_View.xsl b/xslt/report-templates/Group_View.xsl new file mode 100644 index 0000000..123559e --- /dev/null +++ b/xslt/report-templates/Group_View.xsl @@ -0,0 +1,284 @@ +<?xml version="1.0"?> +<!-- WARNING: Tellico uses tc as the internal namespace declaration, and it must be identical here!! --> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:str="http://exslt.org/strings" + extension-element-prefixes="str" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Group View Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<!-- To choose which fields of each entry are printed, change the + string to a space separated list of field names. To know what + fields are available, check the Tellico data file for <field> + elements. --> +<xsl:param name="column-names" select="'title'"/> +<xsl:variable name="columns" select="str:tokenize($column-names)"/> + +<!-- If you want the header row printed, showing which fields + are printed, change this to true(), otherwise false() --> +<xsl:param name="show-headers" select="true()"/> + +<!-- set the maximum image size --> +<xsl:param name="image-height" select="'100'"/> +<xsl:param name="image-width" select="'100'"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data files are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> + +<xsl:key name="fieldsByName" match="tc:field" use="@name"/> +<xsl:key name="imagesById" match="tc:image" use="@id"/> +<xsl:key name="entriesById" match="tc:entry" use="@id"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + <xsl:if test="count($columns) > 3"> + font-size: 80%; + </xsl:if> + background-color: #fff; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + } + td.groupName { + margin-top: 10px; + margin-bottom: 2px; + padding-left: 4px; + background: #ccc; + font-size: 1.1em; + font-weight: bolder; + } + td.fieldName { + margin-top: 10px; + margin-bottom: 2px; + color: #666; + background-color: #ccc; + font-size: 1em; + text-align: center; + font-style: italic; + padding-left: 4px; + padding-right: 4px; + } + tr.r0 { + } + tr.r1 { + background-color: #eee; + } + td.field { + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-right: 5px; + border: 1px solid #eee; + text-align: left; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <table> + <tbody> + <xsl:variable name="fields" select="tc:fields"/> + <xsl:for-each select="tc:group"> + <xsl:sort lang="$lang" select="@title"/> + <tr> + <td class="groupName"> + <xsl:value-of select="@title"/> + </td> + <xsl:for-each select="$columns[position() > 1]"> + <td class="fieldName"> + <xsl:call-template name="field-title"> + <xsl:with-param name="fields" select="$fields"/> + <xsl:with-param name="name" select="."/> + </xsl:call-template> + </td> + </xsl:for-each> + </tr> + + <xsl:for-each select="key('entriesById', tc:entryRef/@id)"> + <tr class="r{position() mod 2}"> + <xsl:apply-templates select="."/> + </tr> + </xsl:for-each> + </xsl:for-each> + + </tbody> + </table> +</xsl:template> + +<xsl:template name="field-title"> + <xsl:param name="fields"/> + <xsl:param name="name"/> + <xsl:variable name="name-tokens" select="str:tokenize($name, ':')"/> + <!-- the header is the title field of the field node whose name equals the column name --> + <xsl:choose> + <xsl:when test="$fields"> + <xsl:value-of select="$fields/tc:field[@name = $name-tokens[last()]]/@title"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$name-tokens[last()]"/> + </xsl:otherwise> + </xsl:choose> +</xsl:template> + +<xsl:template match="tc:entry"> + <!-- stick all the descendants into a variable --> + <xsl:variable name="current" select="descendant::*"/> + <xsl:variable name="entry" select="."/> + + <xsl:for-each select="$columns"> + <xsl:variable name="column" select="."/> + + <!-- find all descendants whose name matches the column name --> + <xsl:variable name="numvalues" select="count($current[local-name() = $column])"/> + <!-- if the field node exists, output its value, otherwise put in a space --> + <td class="field"> + <xsl:choose> + <!-- when there is at least one value... --> + <xsl:when test="$numvalues > 1"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <xsl:when test="$numvalues = 1"> + <xsl:for-each select="$current[local-name() = $column]"> + + <xsl:variable name="field" select="key('fieldsByName', $column)"/> + <xsl:choose> + + <!-- boolean values end up as 'true', output 'X' --> + <xsl:when test="$field/@type=4 or $field/@type=6"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <!-- next, check for images --> + <xsl:when test="$field/@type=10"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <img> + <xsl:attribute name="src"> + <xsl:value-of select="concat($imgdir, .)"/> + </xsl:attribute> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="$image-width"/> + <xsl:with-param name="limit-height" select="$image-height"/> + <xsl:with-param name="image" select="key('imagesById', .)"/> + </xsl:call-template> + </img> + </xsl:when> + + <!-- if it's a date, format with hyphens --> + <xsl:when test="$field/@type=12"> + <xsl:attribute name="style"> + <xsl:text>text-align: center; padding-left: 5px</xsl:text> + </xsl:attribute> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:when> + + <!-- handle URL here, so no link created --> + <xsl:when test="$field/@type=7"> + <xsl:value-of select="."/> + </xsl:when> + + <!-- finally, it's just a regular value --> + <xsl:otherwise> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$column"/> + </xsl:call-template> + </xsl:otherwise> + + </xsl:choose> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> + </xsl:choose> + </td> + </xsl:for-each> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Image_List.xsl b/xslt/report-templates/Image_List.xsl new file mode 100644 index 0000000..78c596f --- /dev/null +++ b/xslt/report-templates/Image_List.xsl @@ -0,0 +1,250 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:str="http://exslt.org/strings" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="str" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Image List Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<!-- To choose which fields of each entry are printed, change the + string to a space separated list of field names. To know what + fields are available, check the Tellico data file for <field> + elements. --> +<xsl:param name="column-names" select="'title'"/> +<xsl:variable name="columns" select="str:tokenize($column-names)"/> + +<!-- set the maximum image size --> +<xsl:param name="image-height" select="'150'"/> +<xsl:param name="image-width" select="'150'"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data files are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> + +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + color: #000; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + div.r0 { + border: 1px inset #666; + clear: left; + padding: 10px 10px 0px 10px; + background-color: #eee; + } + div.r1 { + border: 1px inset #666; + clear: left; + padding: 10px 10px 0px 10px; + background-color: #ddd; + } + img.float { + float: left; + margin-right: 10px; + margin-bottom: 10px; + border: 2px outset #ccc; + } + td.title { + font-size: 1.4em; + font-weight: bold; + } + td.fieldName { + color: #666; + vertical-align: top; + } + td.fieldValue { + padding-left: 4px; + font-weight: bold; + vertical-align: top; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <!-- find first image field --> + <xsl:variable name="image-field" select="tc:fields/tc:field[@type=10][1]/@name"/> + + <xsl:for-each select="tc:entry"> + <xsl:sort lang="$lang" select=".//tc:title[1]"/> + <xsl:variable name="entry" select="."/> + + <div class="r{position() mod 2}"> + <xsl:variable name="id" select="./*[local-name() = $image-field]"/> + <xsl:if test="$id"> + <img class="float"> + <xsl:attribute name="src"> + <xsl:value-of select="concat($imgdir, $id)"/> + </xsl:attribute> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="$image-width"/> + <xsl:with-param name="limit-height" select="$image-height"/> + <xsl:with-param name="image" select="key('imagesById', $id)"/> + </xsl:call-template> + </img> + </xsl:if> + + <table> + <thead> + <tr> + <td colspan="2" class="title"> + <xsl:value-of select=".//tc:title[1]"/> + </td> + </tr> + </thead> + + <tbody> + <!-- don't repeat title --> + <xsl:for-each select="$columns[. != 'title']"> + <!-- no other images allowed --> + <xsl:if test="$entry/../tc:fields/tc:field[@name = current()]/@type != 10"> + <xsl:call-template name="field-output"> + <xsl:with-param name="entry" select="$entry"/> + <!-- can't use a key, the context is not the document --> + <xsl:with-param name="field" select="$entry/../tc:fields/tc:field[@name = current()]"/> + </xsl:call-template> + </xsl:if> + </xsl:for-each> + + <!-- add all paragraph fields, too --> + <xsl:for-each select="../tc:fields/tc:field[@type = 2]"> + <xsl:call-template name="field-output"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="."/> + </xsl:call-template> + + </xsl:for-each> + </tbody> + </table> + <div style="clear: left"/> + </div> + </xsl:for-each> +</xsl:template> + +<xsl:template name="field-output"> + <xsl:param name="entry"/> + <xsl:param name="field"/> + <tr> + <td class="fieldName"> + <!-- can't use key here, context is not in document --> + <xsl:value-of select="$field/@title"/> + <xsl:text>: </xsl:text> + </td> + + <td class="fieldValue"> + <xsl:variable name="numvalues" select="count($entry//*[local-name() = $field/@name])"/> + + <xsl:choose> + <xsl:when test="$numvalues > 1"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$field/@name"/> + </xsl:call-template> + </xsl:when> + + <xsl:when test="$numvalues = 1"> + <xsl:choose> + + <!-- boolean values end up as 'true', output 'X' --> + <xsl:when test="$field/@type=4 and . = 'true'"> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$field/@name"/> + </xsl:call-template> + </xsl:when> + + <!-- handle URL here, so no link created --> + <xsl:when test="$field/@type=7"> + <xsl:value-of select="$entry/*[local-name() = $field/@name]"/> + </xsl:when> + + <!-- finally, it's just a regular value --> + <xsl:otherwise> + <xsl:call-template name="simple-field-value"> + <xsl:with-param name="entry" select="$entry"/> + <xsl:with-param name="field" select="$field/@name"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:when> + + <xsl:otherwise> + <xsl:text> </xsl:text> + </xsl:otherwise> + </xsl:choose> + </td> + </tr> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Loan_View.xsl b/xslt/report-templates/Loan_View.xsl new file mode 100644 index 0000000..d52f74c --- /dev/null +++ b/xslt/report-templates/Loan_View.xsl @@ -0,0 +1,201 @@ +<?xml version="1.0"?> +<!-- WARNING: Tellico uses tc as the internal namespace declaration, and it must be identical here!! --> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:str="http://exslt.org/strings" + extension-element-prefixes="str" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Group View Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:key name="entriesById" match="tc:entry" use="@id"/> +<xsl:key name="loansByDate" match="tc:loan" use="@dueDate"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + margin-bottom: 30px; + } + td.groupName { + margin-top: 10px; + margin-bottom: 2px; + padding-left: 4px; + background: #ccc; + font-size: 1.1em; + font-weight: bolder; + } + td.fieldName { + margin-top: 10px; + margin-bottom: 2px; + color: #666; + background-color: #ccc; + font-size: 1.1em; + text-align: center; + font-style: italic; + padding-left: 4px; + padding-right: 4px; + } + tr.r0 { + } + tr.r1 { + background-color: #eee; + } + td.field { + margin: 0px; + padding: 0px 10px 0px 10px; + border: 1px solid #eee; + text-align: left; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <table> + <tbody> + <!-- TODO: this would need to be fixed for multiple collections --> + <xsl:for-each select="../tc:borrowers/tc:borrower/tc:loan[generate-id(.)=generate-id(key('loansByDate', @dueDate)[1])]"> + <xsl:sort lang="$lang" select="@dueDate"/> + <tr> + <td class="groupName"> + <xsl:value-of select="@dueDate"/> + </td> + <td class="fieldName"><i18n>Borrower</i18n></td> + <td class="fieldName"><i18n>Loan Date</i18n></td> + <td class="fieldName"><i18n>Note</i18n></td> + </tr> + + <xsl:for-each select="key('loansByDate', @dueDate)"> + <tr class="r{position() mod 2}"> + <td class="field"> + <xsl:value-of select="key('entriesById', @entryRef)//tc:title"/> + </td> + <td class="field"> + <xsl:value-of select="../@name"/> + </td> + <td class="field"> + <xsl:value-of select="@loanDate"/> + </td> + <td class="field"> + <p><xsl:value-of select="text()"/></p> + </td> + </tr> + </xsl:for-each> + </xsl:for-each> + + </tbody> + </table> + + <table> + <tbody> + <!-- TODO: this would need to be fixed for multiple collections --> + <xsl:for-each select="../tc:borrowers/tc:borrower"> + <xsl:sort lang="$lang" select="@name"/> + <tr> + <td class="groupName"> + <xsl:value-of select="@name"/> + </td> + <td class="fieldName"><i18n>Loan Date</i18n></td> + <td class="fieldName"><i18n>Due Date</i18n></td> + <td class="fieldName"><i18n>Note</i18n></td> + </tr> + + <xsl:for-each select="tc:loan"> + <tr class="r{position() mod 2}"> + <td class="field"> + <xsl:value-of select="key('entriesById', @entryRef)//tc:title"/> + </td> + <td class="field"> + <xsl:value-of select="@loanDate"/> + </td> + <td class="field"> + <xsl:value-of select="@dueDate"/> + </td> + <td class="field"> + <p><xsl:value-of select="text()"/></p> + </td> + </tr> + </xsl:for-each> + </xsl:for-each> + + </tbody> + </table> + + <!-- + <h4><a href="http://www.periapsis.org/tellico/"><i18n>Generated by Tellico</i18n></a></h4> +--> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Makefile.am b/xslt/report-templates/Makefile.am new file mode 100644 index 0000000..36c6dca --- /dev/null +++ b/xslt/report-templates/Makefile.am @@ -0,0 +1,21 @@ +####### kdevelop will overwrite this part!!! (begin)########## + + +EXTRA_DIST = Column_View.xsl Title_Listing_(Horizontal).xsl\ + Title_Listing_(Vertical).xsl Group_View.xsl Image_List.xsl \ + Loan_View.xsl Group_Summary.xsl Tri-Column.xsl + +####### kdevelop will overwrite this part!!! (end)############ + +xsldir = $(kde_datadir)/tellico/report-templates +xsl_DATA = Column_View.xsl Title_Listing_(Horizontal).xsl \ + Title_Listing_(Vertical).xsl Group_View.xsl Image_List.xsl \ + Loan_View.xsl Group_Summary.xsl Tri-Column.xsl + +KDE_OPTIONS = noautodist + +CLEANFILES = *~ + +# probably a better way to do this +uninstall-hook: + -if [ -d $(xsldir) ]; then rmdir $(xsldir); fi diff --git a/xslt/report-templates/Title_Listing_(Horizontal).xsl b/xslt/report-templates/Title_Listing_(Horizontal).xsl new file mode 100644 index 0000000..30b9c95 --- /dev/null +++ b/xslt/report-templates/Title_Listing_(Horizontal).xsl @@ -0,0 +1,146 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="exsl" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Title List Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:param name="num-columns" select="3"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + color: #000; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + } + td { + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-right: 5px; + border: 1px solid #eee; + text-align: left; + } + tr.r0 { + background-color: #fff; + } + tr.r1 { + background-color: #eee; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <!-- first, build sorted list --> + <xsl:variable name="sorted-entries"> + <xsl:for-each select="tc:entry"> + <xsl:sort lang="$lang" select=".//tc:title[1]"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </xsl:variable> + + <table> + <tbody> + +<!-- + <xsl:variable name="nrows" + select="ceiling(count(tc:entry) div $num-columns)"/> +--> + <xsl:for-each select="exsl:node-set($sorted-entries)/tc:entry[position() mod $num-columns = 1]"> + <tr class="r{position() mod 2}"> + <xsl:apply-templates select=".|following-sibling::tc:entry[position() < $num-columns]"/> + </tr> + </xsl:for-each> + + </tbody> + </table> + +</xsl:template> + +<xsl:template match="tc:entry"> + <td> + <xsl:for-each select=".//tc:title"> + <xsl:value-of select="."/> + <xsl:if test="position() < last()"> + <xsl:text>; </xsl:text> + <br/> + </xsl:if> + </xsl:for-each> +</td> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Title_Listing_(Vertical).xsl b/xslt/report-templates/Title_Listing_(Vertical).xsl new file mode 100644 index 0000000..79b6820 --- /dev/null +++ b/xslt/report-templates/Title_Listing_(Vertical).xsl @@ -0,0 +1,156 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="exsl" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Title List Report + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:param name="num-columns" select="3"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + color: #000; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + table { + margin-left: auto; + margin-right: auto; + } + td { + margin-left: 0px; + margin-right: 0px; + padding-left: 10px; + padding-right: 5px; + border: 1px solid #eee; + text-align: left; + } + tr.r0 { + background-color: #fff; + } + tr.r1 { + background-color: #eee; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <table> + <tbody> + + <!-- first, build sorted list --> + <xsl:variable name="sorted-entries"> + <xsl:for-each select="tc:entry"> + <xsl:sort lang="$lang" select=".//tc:title[1]"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </xsl:variable> + + <xsl:variable name="nrows" + select="ceiling(count(tc:entry) div $num-columns)"/> + + <!-- + <xsl:for-each select="exsl:node-set($sorted-entries)/tc:entry[position() mod $num-columns = 1]"> + <tr class="r{position() mod 2}"> + <xsl:apply-templates select=".|following-sibling::tc:entry[position() < $num-columns]"/> + </tr> + </xsl:for-each> +--> + <xsl:for-each select="exsl:node-set($sorted-entries)/tc:entry[position() <= $nrows]"> + <xsl:variable name="idx" select="position()"/> + <tr class="r{$idx mod 2}"> + <xsl:apply-templates select="."/> + <xsl:for-each + select="exsl:node-set($sorted-entries)/tc:entry[position() > + $nrows and position() mod $nrows = ($idx mod $nrows)]"> + <xsl:apply-templates select="."/> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> +</xsl:template> + +<xsl:template match="tc:entry"> + <td> + <xsl:for-each select=".//tc:title"> + <xsl:value-of select="."/> + <xsl:if test="position() < last()"> + <xsl:text>; </xsl:text> + <br/> + </xsl:if> + </xsl:for-each> +</td> +</xsl:template> + +</xsl:stylesheet> +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> diff --git a/xslt/report-templates/Tri-Column.xsl b/xslt/report-templates/Tri-Column.xsl new file mode 100644 index 0000000..d38dd5f --- /dev/null +++ b/xslt/report-templates/Tri-Column.xsl @@ -0,0 +1,234 @@ +<?xml version="1.0"?> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:tc="http://periapsis.org/tellico/" + xmlns:exsl="http://exslt.org/common" + extension-element-prefixes="exsl" + exclude-result-prefixes="tc" + version="1.0"> + +<!-- + =================================================================== + Tellico XSLT file - Tri-Column Report + Modified from VideoDB + + Copyright (C) 2005-2006 Robby Stephenson - [email protected] + + This XSLT stylesheet is designed to be used with the 'Tellico' + application, which can be found at http://www.periapsis.org/tellico/ + + =================================================================== +--> + +<!-- import common templates --> +<!-- location depends on being installed correctly --> +<xsl:import href="../tellico-common.xsl"/> + +<xsl:output method="html" + indent="yes" + doctype-public="-//W3C//DTD HTML 4.01//EN" + doctype-system="http://www.w3.org/TR/html4/strict.dtd" + encoding="utf-8"/> + +<xsl:param name="filename"/> +<xsl:param name="cdate"/> + +<!-- Sort using user's preferred language --> +<xsl:param name="lang"/> + +<xsl:variable name="image-field" select="tc:tellico/tc:collection[1]/tc:fields/tc:field[@type=10][1]/@name"/> + +<!-- set the maximum image size --> +<xsl:param name="image-height" select="'150'"/> +<xsl:param name="image-width" select="'150'"/> + +<xsl:param name="datadir"/> <!-- dir where Tellico data files are located --> +<xsl:param name="imgdir"/> <!-- dir where field images are located --> + +<xsl:key name="imagesById" match="tc:image" use="@id"/> + +<xsl:template match="/"> + <xsl:apply-templates select="tc:tellico"/> +</xsl:template> + +<xsl:template match="tc:tellico"> + <html> + <head> + <style type="text/css"> + body { + font-family: sans-serif; + background-color: #fff; + color: #000; + } + #header-left { + margin-top: 0; + float: left; + font-size: 80%; + font-style: italic; + } + #header-right { + margin-top: 0; + float: right; + font-size: 80%; + font-style: italic; + } + h1.colltitle { + margin: 0px; + padding-bottom: 5px; + font-size: 2em; + text-align: center; + } + tr.r0 { + border: 1px inset #666; + background-color: #eee; + } + tr.r1 { + border: 1px inset #666; + background-color: #ddd; + } + img.float { + float: left; + margin-right: 10px; + margin-bottom: 10px; + border: 2px outset #ccc; + } + td { + vertical-align: top; + } + span.title { + font-size: 1.2em; + font-weight: bold; + } + span.info { + font-size: 1.1em; + font-style italic; + color: #006; + } + span.plot { + font-size: 1em; + } + </style> + <title>Tellico</title> + </head> + <body> + <xsl:apply-templates select="tc:collection"/> + </body> + </html> +</xsl:template> + +<xsl:template match="tc:collection[@type!=3]"> + <h1 class="colltitle"> + <i18n>This template is meant for video collections only.</i18n> + </h1> +</xsl:template> + +<xsl:template match="tc:collection[@type=3]"> + <p id="header-left"><xsl:value-of select="$filename"/></p> + <p id="header-right"><xsl:value-of select="$cdate"/></p> + <h1 class="colltitle"> + <xsl:value-of select="@title"/> + </h1> + + <!-- first, build sorted list --> + <xsl:variable name="sorted-entries"> + <xsl:for-each select="tc:entry"> + <xsl:sort lang="$lang" select=".//tc:title[1]"/> + <xsl:copy-of select="."/> + </xsl:for-each> + </xsl:variable> + + <!-- needed for key context --> + <xsl:variable name="coll" select="."/> + + <table class="tablelist" cellpadding="0" cellspacing="0" width="100%"> + <colgroup width="33%"/> + <colgroup width="34%"/> + <colgroup width="33%"/> + <tbody> + <!-- three columns --> + <!-- have to pass in image width and height because + context changes inside the exsl:node-set --> + <xsl:variable name="entries" select="exsl:node-set($sorted-entries)/tc:entry"/> + + <xsl:for-each select="$entries[position() mod 3 = 1]"> + <xsl:variable name="e1" select="."/> + <xsl:variable name="e2" select="$e1/following-sibling::tc:entry[position() = 1]"/> + <xsl:variable name="e3" select="$e2/following-sibling::tc:entry[position() = 1]"/> + + <tr class="r{position() mod 2}"> + + <!-- switch context back to document --> + <xsl:for-each select="$coll"> + + <td> + <xsl:apply-templates select="$e1"> + <xsl:with-param name="img" select="key('imagesById', $e1/*[local-name() = $image-field])"/> + </xsl:apply-templates> + </td> + <td> + <xsl:apply-templates select="$e2"> + <xsl:with-param name="img" select="key('imagesById', $e2/*[local-name() = $image-field])"/> + </xsl:apply-templates> + </td> + <td> + <xsl:apply-templates select="$e3"> + <xsl:with-param name="img" select="key('imagesById', $e3/*[local-name() = $image-field])"/> + </xsl:apply-templates> + </td> + </xsl:for-each> + </tr> + </xsl:for-each> + + </tbody> + </table> + +</xsl:template> + +<xsl:template match="tc:entry"> + <xsl:param name="img"/> + <table> + <tbody> + <tr> + <td> + <xsl:variable name="id" select="./*[local-name() = $image-field]"/> + <xsl:if test="$id"> + <img class="float" alt=" "> + <xsl:attribute name="src"> + <xsl:value-of select="concat($imgdir, $id)"/> + </xsl:attribute> + <xsl:call-template name="image-size"> + <xsl:with-param name="limit-width" select="$image-width"/> + <xsl:with-param name="limit-height" select="$image-height"/> + <xsl:with-param name="image" select="$img"/> + </xsl:call-template> + </img> + </xsl:if> + </td> + <td> + <span class="title"> + <xsl:value-of select=".//tc:title[1]"/> + </span> + <br/> + <span class="info"> + <xsl:text>[</xsl:text> + <xsl:value-of select=".//tc:year[1]"/> + <xsl:text>; </xsl:text> + <xsl:value-of select=".//tc:director[1]"/> + <xsl:text>]</xsl:text> + </span> + <br/> + <span class="plot"> + <xsl:value-of select="normalize-space(substring(./tc:plot, 1, 150))" disable-output-escaping="yes"/> + <xsl:text> …</xsl:text> + </span> + </td> + </tr> + </tbody> + </table> +</xsl:template> + +</xsl:stylesheet> + +<!-- Local Variables: --> +<!-- sgml-indent-step: 1 --> +<!-- sgml-indent-data: 1 --> +<!-- End: --> |