2017-02-20 3 views
0

あなたは、XSLTの.hereに私は最後の二つのノードを取得して助けてください可能性が私のコード http://xsltransform.net/bwdwsJ/1どのようにXSLTの最後の2つのノードを表示するには?

expectoutput

<h1>Preview your result as PDF when doctype is set to XML and your document starts with 
     root element of XSL-FO. Apache FOP is used to generate the PDF 
    </h1> 
    <h1>Added some links to useful XSLT sites</h1> 

XSLTコード

<xsl:template match="/"> 
     <hmtl> 
     <head> 
      <title>New Version!</title> 
     </head> 
     <xsl:for-each select="ul/li[last() &gt;2]"> 
      <h1><xsl:value-of select="."/></h1> 
     </xsl:for-each> 
     </hmtl> 
    </xsl:template> 

XML

ですショートだが効果的な
<?xml version="1.0" encoding="UTF-8"?> 

    <ul> 
     <li>A new XSLT engine is added: Saxon 9.5 EE, with a license (thank you Michael Kay!)</li> 
     <li>XSLT 3.0 support when using the new Saxon 9.5 EE engine!</li> 
     <li>Preview your result as HTML when doctype is set to HTML (see this example)</li> 
     <li>Preview your result as PDF when doctype is set to XML and your document starts with root element of XSL-FO. Apache FOP is used to generate the PDF</li> 
     <li>Added some links to useful XSLT sites</li> 
    </ul> 

答えて

0

:現在、処理ノードのul/li[position() &gt;= last()-1]

ポジションは1

に示され

マイナス大きいか最後の要素のインデックスよりも等しくなければなりませんXPathの式:

/ul/li[position()>count(/ul/li)-2] 
関連する問題