[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Sorted node set and following-sibling axis
Hi Nick,
Tempore 19:11:02, die 08/10/2005 AD, hinc in xsl-list@xxxxxxxxxxxxxxxxxxxxxx scripsit Nick Fitzsimons <nick@xxxxxxxxxxxxxx>: What I require is the following:
here's the xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:key name="xID" match="article" use="generate-id()"/> <xsl:variable name="groupSize" select="2"/> <xsl:template match="articles"> <xsl:call-template name="group"> <xsl:with-param name="idList"> <xsl:for-each select="article"> <xsl:sort select="@priority" data-type="number" order="descending" /> <xsl:value-of select="generate-id()"/> <xsl:text>-</xsl:text> <xsl:if test="position() mod $groupSize=0 or position()=last()"> <xsl:text>|</xsl:text> </xsl:if> </xsl:for-each> </xsl:with-param> </xsl:call-template> </xsl:template> <xsl:template name="group"> <xsl:param name="idList"/> <xsl:variable name="PartIdlist" select="substring-before($idList,'|')"/> <xsl:if test="$PartIdlist"> <div> <xsl:call-template name="animate"> <xsl:with-param name="idList" select="$PartIdlist"/> </xsl:call-template> </div> <xsl:call-template name="group"> <xsl:with-param name="idList" select="substring-after($idList,'|')"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="animate"> <xsl:param name="idList"/> <xsl:variable name="id" select="substring-before($idList,'-')"/> <xsl:if test="$id"> <xsl:apply-templates select="key('xID',$id)"/> <xsl:call-template name="animate"> <xsl:with-param name="idList" select="substring-after($idList,'-')"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template match="article"> <p><xsl:value-of select="title" /><xsl:value-of select="@priority" /></p> </xsl:template> </xsl:stylesheet>
|
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
|