使用:
(//p)[position() > count(//p) - 3]
p
これにより、XMLドキュメントの最後(最大3つ)の要素が選択されます。
XSLTベースの検証:
<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="node()|@*">
<xsl:copy-of select="(//p)[position() > count(//p) - 3]"/>
</xsl:template>
</xsl:stylesheet>
質問で参照されているドキュメントに対して適用されると、この変換はXPath式を評価し、選択されたp
要素を出力します。
結果は次のとおりです。
<p>
If you would like to share your thoughts and memories,<br/> we will deliver your message to the family.<br/>
<a href="mailto:staff@sturmfh.com?Subject=For%20the%20Family%20of%20Lyle%20Meier">Click</a>
<a href="mailto:staff@sturmfh.com?Subject=For%20the%20Family%20of%20Lyle%20Meier">
<img src="/images/email_condol.gif" alt="Logo" border="0" align="middle"/>
</a>
<a href="mailto:staff@sturmfh.com?Subject=For%20the%20Family%20of%20Lyle%20Meier">here</a>.
</p>
<p>To Request a Tribute Folder
<br/>
<a href="./obit-foldreq.jhtml?fname=Lyle&lname=Meier">Click</a>
<a href="./obit-foldreq.jhtml?fname=Lyle&lname=Meier">
<img src="/images/email_condol.gif" border="0" alt="View" align="top"/>
</a>
<a href="./obit-foldreq.jhtml?fname=Lyle&lname=Meier">here</a>
</p>