Get last several nodes in XSL, spanning parents
I have XML that looks like this:
<2011>
<开发者_StackOverflow社区;05>
(item)
(item)
</05>
<06>
(item)
</06>
</2011>
I'd like to get the last three items. However, I can't just get the last three items of the last item in the list, because sometimes that last item doesn't have three (in this example, it's if we're in a new month and there's only one item posted so far).
How do I go about getting the last three items without worrying about which parent they belong to?
This is the XSLT I was speaking about, assuming the @polishchuk input:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="(/*/*/*)[position()>last()-3]"/>
</xsl:template>
</xsl:stylesheet>
精彩评论