воскресенье, 3 октября 2010 г.

XSL: node-sets. Get value from variable


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
extension-element-prefixes="exsl"
>
<xsl:output method="xml" omit-xml-declaration="yes" />

<xsl:template match="/">
<xsl:variable name="author-id" ><xsl:value-of select="data/get-advice-last/entry/author/item/@id" /></xsl:variable>
<xsl:variable name="author" ><xsl:copy-of select="data/advice-author/entry[@id=$author-id]" /></xsl:variable>
<div class="h"><h1>Советы</h1><h3>диетолога</h3></div>
<div style="margin-bottom:5px;font-weight:bold;"><xsl:value-of select="data/get-advice-last/entry/title" /></div>

<div style="font-size:.9em;"><img style="float:left;border:1px solid #3D93E5;margin:1px 10px 10px 0px;" src="{$root}/image/2/80/100/5{exsl:node-set($author)/entry/photo/@path}/{exsl:node-set($author)/entry/photo/filename}" />
Рассказывает <xsl:value-of select="exsl:node-set($author)/entry/fio" />,
<xsl:value-of select="exsl:node-set($author)/entry/description" />
</div>
<div><a href="{$root}/advice/{data/get-advice-last/entry/@id}">Читать дальше...</a></div>
</xsl:template>

</xsl:stylesheet>