はい、 と の文字列値は異なる場合があります$page
。@page
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="/*">
<xsl:apply-templates select="*[@page mod 2 = 0]"/>
</xsl:template>
<xsl:template match="par">
<xsl:variable name="pos">
<xsl:value-of select="position()"/>
</xsl:variable>
<xsl:variable name="page">
<xsl:value-of select="../par[position()=$pos]/@page"/>
</xsl:variable>
<xsl:if test="$page!=''">
<xsl:if test="$page!=@page">
<div style="text-align:right;page-break-before:always">
<font color="#000000" style="font-style:normal;text-decoration:none;font-weight:normal"> -
<xsl:value-of select="$page"/> -
<br/>
</font>
</div>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
この変換が次の XML ドキュメントに適用される場合:
<t>
<par page="1"/>
<par page="2"/>
<par page="3"/>
<par page="4"/>
<par page="5"/>
<par page="6"/>
<par page="7"/>
</t>
生成された結果はすべて、上記のコードの$page
との不等式によるもの@page
です。
<div style="text-align:right;page-break-before:always">
<font color="#000000" style="font-style:normal;text-decoration:none;font-weight:normal"> -
1 -
<br/>
</font>
</div>
<div style="text-align:right;page-break-before:always">
<font color="#000000" style="font-style:normal;text-decoration:none;font-weight:normal"> -
2 -
<br/>
</font>
</div>
<div style="text-align:right;page-break-before:always">
<font color="#000000" style="font-style:normal;text-decoration:none;font-weight:normal"> -
3 -
<br/>
</font>
</div>
説明:
テンプレート内または 内xsl:for-each
の式:
position()
現在の node-list内の現在のノードの位置です。これは通常、同じ名前の兄弟のノードセット内の現在のノードの位置と同じではありません。