| Новости | FAQ | Авторы | Документация | В действии | Библиотека |
| Инструменты | Полезные ссылки | Хостинги | Скачать | Примеры | Форум |
baibaratsky 13.05.2005 14:17
Перед тем, как напустить на текст темплейты, проверяем, есть ли в нём непарный cut. Если есть, то обрабатываем соответствующим образом.<xsl:choose>
<xsl:when test="not(string(content/cut))">
<xsl:apply-templates select="content/cut" mode="null"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="content"/>
</xsl:otherwise>
</xsl:choose>Теперь сама обработка cut'а: <xsl:template match="cut">
<xsl:call-template name="cut"/>
</xsl:template>
<xsl:template match="cut" mode="null">
<xsl:apply-templates select="preceding-sibling::node()"/>
<xsl:call-template name="cut"/>
</xsl:template>
<!-- Common part of template "cut" -->
<xsl:template name="cut">
<a>
<xsl:attribute name="href"><!-- Here I generate a link --></xsl:attribute>
<xsl:choose>
<xsl:when test="string(@text)">
<xsl:value-of select="@text"/>
</xsl:when>
<xsl:otherwise>читать дальше…</xsl:otherwise>
</xsl:choose>
</a>
</xsl:template>