|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Ordered Records
It's reaaly not that hard with XSLT :-)
ok an example: so lots of records throughout the XML, you want only to show the smallest 10. Based on your XML I created a little example. First sort your records from small to big, then only do something with the first 10. Cheers RH XSLT: <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/">
<xsl:apply-templates select="//record">
<xsl:sort select="number" data-type="number" />
</xsl:apply-templates>
</xsl:template><xsl:template match="record"> <xsl:choose> <xsl:when test="position() < 11"> <record> <xsl:comment>position = <xsl:value-of select="position()" /></xsl:comment> <xsl:apply-templates select="number" /> </record> </xsl:when> <xsl:otherwise> <xsl:comment>at least 10 records have smaller numbers</xsl:comment> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="number">
<number>
<xsl:apply-templates />
</number>
</xsl:template></xsl:stylesheet> XML
<document>
<record-set>
<record>
<number>100</number>
</record> <record>
<number>5</number>
</record> <record>
<number>102</number>
</record> <record>
<number>51</number>
</record> <record>
<number>101</number>
</record> <record>
<number>52</number>
</record> <record>
<number>12</number>
</record> <record>
<number>15</number>
</record>
</record-set> <record-set>
<record>
<number>19</number>
</record> <record>
<number>29</number>
</record> <record>
<number>10</number>
</record> <record>
<number>19</number>
</record> <record>
<number>291</number>
</record> <record>
<number>30</number>
</record> <record>
<number>99</number>
</record> <record>
<number>59</number>
</record> <record>
<number>10</number>
</record>
</record-set>
</document>HTML: <record> <!--position = 1--> <number>5</number> </record> <record> <!--position = 2--> <number>10</number> </record> <record> <!--position = 3--> <number>10</number> </record> <record> <!--position = 4--> <number>12</number> </record> <record> <!--position = 5--> <number>15</number> </record> <record> <!--position = 6--> <number>19</number> </record> <record> <!--position = 7--> <number>19</number> </record> <record> <!--position = 8--> <number>29</number> </record> <record> <!--position = 9--> <number>30</number> </record> <record> <!--position = 10--> <number>51</number> </record> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> <!--at least 10 records have smaller numbers--> At 12:37 PM 2/4/02 +0100, you wrote: Hi, XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








