2009-06-18 52 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> 
的顺序列出的项目