Click to See Complete Forum and Search --> : Problems regarding XSLT 2.0 - more than one page


mrWindUpBird
07-08-2008, 04:17 PM
Dear fellow forummembers,

Please, help me with the following problem. Underneath my short letter you will find listings of the XSLT (gallery_helpMe.xsl) and the XML-file (gallery_helpMe.xml). The meaning of these listings is generating HTML-pages, together they should be forming a gallery of drawings.

The amount of pages varies. It will be one more than the amount of different categories in the XML-file, gallery_helpMe.XML. The first page should be drawings.htm. It shows all the drawings and categories they belong to. The printed names of the categories are hyperlinks. If you would click on it it brings you to the next generated page, which bears the name of the categorie. On this page you will only see the drawings arranged in that category.

The problematic situation is as follows. All pages are generated, but drawings.htm just shows all the drawings, but the others categorically don't: if you click on one of the categories you don't see any pictures.

I hope that someone knows what I did wrong.

Sincerely yours, Bas

gallery_helpMe.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="gallery_helpMe.xsl"?>
<gallery>
<item category="landscapes">
<picture>http://digart.img.digart.pl/data/img/10/33/miniaturki400/1712270.jpg</picture>
<thumbnail>http://digart.img.digart.pl/data/img/10/33/miniaturki3/1712270.jpg</thumbnail>
</item>
<item category="buildings">
<picture category="buildings">http://digart.img.digart.pl/data/img/93/94/miniaturki400/1687876.jpg</picture>
<thumbnail>http://digart.img.digart.pl/data/img/93/94/miniaturki3/1687876.jpg</thumbnail>
</item>
<item category="landscapes">
<picture>http://digart.img.digart.pl/data/img/35/77/miniaturki400/1656048.jpg</picture>
<thumbnail>http://digart.img.digart.pl/data/img/35/77/miniaturki3/1656048.jpg</thumbnail>
</item>
<item category="buildings">
<picture>http://digart.img.digart.pl/data/img/29/99/miniaturki400/1818536.jpg</picture>
<thumbnail>http://digart.img.digart.pl/data/img/29/99/miniaturki3/1818536.jpg</thumbnail>
</item>
<item category="buildings">
<picture >http://digart.img.digart.pl/data/img/72/6/miniaturki400/1882247.jpg</picture>
<thumbnail>http://digart.img.digart.pl/data/img/72/6/miniaturki100/1882247.jpg</thumbnail>
</item>
</gallery>

gallery_helpMe.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="html" indent="no"/>
<!-- Page configuration variables -->
<xsl:variable name="cellsPerRow" select="5"/>
<!-- Key for grouping by category -->
<xsl:key name="pictures-by-category" match="item" use="@category"/>
<!-- Process the root node to begin the transformation-->
<xsl:template match="/">
<xsl:result-document href="drawings.htm">
<html>
<head>
<title>Gallery</title>
<link rel="stylesheet" href="styles.css" type="text/css"/>
<script type="text/javascript" src="javascripts.js"/>
</head>
<body>
<table width="900" bgcolor="#000000" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="165" align="left" valign="top">
<table bgcolor="#000000" cellspacing="10" cellpadding="0" border="0">
<td>
<xsl:apply-templates select="gallery" mode="index"/>
</td>
</table>
</td>
<td width="621" align="left" valign="top">
<table bgcolor="#000000" border="0" cellspacing="10" cellpadding="0">
<xsl:apply-templates select="gallery"/>
</table>
</td>
</tr>
</table>
</body>
</html>
</xsl:result-document>
</xsl:template>
<!-- Build gallery rows -->
<xsl:template match="gallery">
<xsl:for-each select="item [position() mod $cellsPerRow = 1]">
<tr>
<xsl:apply-templates select=".|following-sibling::item [position() &lt; $cellsPerRow]"/>
</tr>
</xsl:for-each>
</xsl:template>
<!-- Build gallery cells -->
<xsl:template match="item">
<td align="center">
<a href="javascript:Foto('{picture}')">
<img src="{thumbnail}" border="0" align="top"/>
</a>
</td>
<xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Show categories -->
<xsl:template match="gallery" mode="index">
<xsl:for-each select="item[count(. | key('pictures-by-category', @category)[1])=1]">
<xsl:sort select="@category" order="ascending"/>
<p>
<a href="{@category}.htm">
<xsl:value-of select="@category"/>
<!--<xsl:apply-templates select="/" mode="category">-->
<xsl:call-template name="galleryPerCategory">
<xsl:with-param name="category" select="@category"/>
</xsl:call-template>
<!--</xsl:apply-templates>-->
</a>
</p>
</xsl:for-each>
</xsl:template>
<!-- Build Gallery for each category -->
<!--<xsl:template match="/" mode="category">-->
<xsl:template name="galleryPerCategory">
<xsl:param name="category"/>
<xsl:result-document href="{$category}.htm">
<html>
<head>
<title>
<xsl:value-of select="$category"/>
</title>
<link rel="stylesheet" href="styles.css" type="text/css"/>
<script type="text/javascript" src="javascripts.js"/>
</head>
<body>
<table width="900" bgcolor="#000000" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="165" align="left" valign="top">
<table bgcolor="#000000" cellspacing="10" cellpadding="0" border="0">
<td>
<p>
<xsl:value-of select="$category"/>
</p>
<p>
<a href="drawings.htm">Drawings</a>
</p>
</td>
</table>
</td>
<td width="621" align="left" valign="top">
<table bgcolor="#000000" border="0" cellspacing="10" cellpadding="0">
<xsl:apply-templates select="gallery" mode="category">
<!--<xsl:call-template name="rowPerCategory">-->
<xsl:with-param name="category_r"><xsl:value-of select="$category"/></xsl:with-param>
</xsl:apply-templates>
<!--</xsl:call-template>-->
</table>
</td>
</tr>
</table>
</body>
</html>
</xsl:result-document>
</xsl:template>
<!-- Build gallery rows for each category -->
<xsl:template match="gallery" mode="category">
<!--<xsl:template name="rowPerCategory">-->
<xsl:param name="category_r"/>
<xsl:for-each select="item/@category[.=$category_r] [position() mod $cellsPerRow = 1]">
<p><xsl:value-of select="."/></p>
<tr>
<xsl:apply-templates select=".|following-sibling::item [position() &lt; $cellsPerRow]" mode="category"/>
</tr>
</xsl:for-each>
</xsl:template>
<!-- Build gallery cells for each category -->
<xsl:template match="item" mode="category">
<td align="center">
<a href="javascript:Foto('{picture}')">
<img src="{thumbnail}" border="0" align="top"/>
</a>
</td>
<xsl:if test="(position() = last()) and (position() &lt; $cellsPerRow)">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$cellsPerRow - position()"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- Fillercells -->
<xsl:template name="FillerCells">
<xsl:param name="cellCount"/>
<!--<td> </td>-->
<xsl:if test="$cellCount > 1">
<xsl:call-template name="FillerCells">
<xsl:with-param name="cellCount" select="$cellCount - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>