tags:

views:

45

answers:

2

I have a list of items being returned in xml. each item has various elements. one of the elements is "Position" which takes a value between 0-6

if Position is 0 then the item should not be shown, but if its between 1 and 6 I need it to be shown.

how can i do the xslt so that it will list the items by order of "Position"

A: 
<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>

or

<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>
Tomalak