У меня есть шаблон:Конкретная шаблон для первого элемента
<xsl:template match="paragraph">
...
</xsl:template>
я называю это:
<xsl:apply-templates select="paragraph"/>
Для первого элемента, что нужно сделать:
<xsl:template match="paragraph[1]">
...
<xsl:apply-templates select="."/><!-- I understand that this does not work -->
...
</xsl:template>
Как звоните <xsl:apply-templates select="paragraph"/>
(для первого элемента paragraph
) из шаблона <xsl:template match="paragraph[1]">
?
До сих пор у меня что-то вроде петли.
Я решить эту проблему так (но я не люблю его):
<xsl:for-each select="paragraph">
<xsl:choose>
<xsl:when test="position() = 1">
...
<xsl:apply-templates select="."/>
...
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>