In the if block below I want to be also test whether @Timestamp is smaller than the previous Message's timestamp. How can I achieve this?
<xsl:for-each select="Message">
<xsl:sort select="position()" data-type="number" order="descending"/>
<xsl:variable name="newclass">
<xsl:if test="@Timestamp + 60 > $ctimestamp">new</xsl:if>
</xsl:variable>
<tr><td class="debugtime">
&l开发者_高级运维t;xsl:value-of select="@Time"/>
</td><td class="{$newclass}">
<xsl:value-of select="node()"/>
</td></tr>
</xsl:for-each>
Example XML
<Message Time="2010/06/17 04:23:32" Timestamp="1276773812">message1</Message>
<Message Time="2010/06/17 04:23:32" Timestamp="1276773812">message2</Message>
<Message Time="2010/06/17 04:23:33" Timestamp="1276773813">message3</Message>
<Message Time="2010/06/17 04:23:33" Timestamp="1276773813">message4</Message>
Update:
I have implemented both variations of the current answers but to no luck. It always doesn't seem to work properly for the second elements onwards, in that it will bold the first correctly but no more (although sometimes it will do the third). Updated if block code below.
<xsl:if test="@Timestamp + 60 > $ctimestamp">
<xsl:if test="position() = 1">
new
</xsl:if>
<xsl:if test="position() != 1 and ../Message[position()-1]/@Timestamp - 1 < @Timestamp">
new
</xsl:if>
</xsl:if>
@Timestamp < preceding-sibling::Message[1]/@Timestamp
I haven't tested this solution, but this should do you.
<xsl:for-each select="Message">
<xsl:sort select="position()" data-type="number" order="descending"/>
<xsl:variable name="newclass">
<xsl:if test="position() != 1">
<xsl:if test="..\Message[position()-1]@Timestamp < @Timestamp">new</xsl:if>
</xsl:if>
<xsl:if test="position() = 1">
new
</xsl:if>
</xsl:variable>
<tr><td class="debugtime">
<xsl:value-of select="@Time"/>
</td><td class="{$newclass}">
<xsl:value-of select="node()"/>
</td></tr>
</xsl:for-each>
加载中,请稍侯......
精彩评论