2009-06-18 49 views
1

我有一個項目列表的XML返回。每個項目都有各種元素。其中一個元素是「位置」 ,其值介於0-6之間xslt排序

如果位置爲0,則不應顯示該項目,但如果項目在1和6之間,則需要顯示該項目。

我該怎麼辦了XSLT,這樣它會通過「位置」

回答

0
<xsl:template match="list_of_items"> 
    <xsl:apply-templates select="item"> 
    <xsl:sort select="position" data-type="number" /> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="item"> 
    <xsl:if test="position &gt; 0"> 
    <xsl:copy-of select="." /> 
    </xsl:if> 
</xsl:template> 

<xsl:template match="list_of_items"> 
    <xsl:apply-templates select="item[position &gt; 0]"> 
    <xsl:sort select="position" data-type="number" /> 
    </xsl:apply-templates> 
</xsl:template> 

<xsl:template match="item"> 
    <xsl:copy-of select="." /> 
</xsl:template> 
的順序列出的項目