| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
DSHa 29.10.2011 01:17
Обрабатываем XML создаём файл tag.xsl.<?xml version="1.0" encoding="utf-8" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates />
</body>
</html>
</xsl:template>
<xsl:template match="cloud">
<xsl:variable name="maxfont">20</xsl:variable>
<xsl:variable name="minfont">8</xsl:variable>
<xsl:variable name="theMax" select="row[not(weight < ../row/weight)]/weight" />
<xsl:variable name="theMin" select="row[not(weight > ../row/weight)]/weight" />
<div>
<xsl:apply-templates select="row">
<xsl:with-param name="minfont" select="$minfont"/>
<!-- <xsl:with-param name="pixInWeight" select="($maxfont - $minfont) div ($theMax - $theMin)"> -->
<xsl:with-param name="pixInWeight">
<xsl:choose>
<xsl:when test="($theMax - $theMin)=0">0</xsl:when>
<xsl:otherwise>
<xsl:value-of select="($maxfont - $minfont) div ($theMax - $theMin)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:apply-templates>
</div>
</xsl:template>
<xsl:template match="row">
<xsl:param name="minfont"/>
<xsl:param name="pixInWeight"/>
<xsl:variable name="size" select="$minfont + floor(weight*$pixInWeight)"/>
<a href="/catalog/index.html?id_tag={tag_id}" style="font-size: {$size}px">
<xsl:value-of select="name" />
</a>
<xsl:if test="position() != last()">
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
</xsl:stylesheet>