|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XSL resources - Flat to hierarchy - Common ancesto
Hey Ben,
Ben Simkins wrote: Three questions in one mail: 1. Does anyone know of a public 'knowledgebase' type site where there are lots of examples of solutions to different problems, classified in a way which avoids spending hours trawling through threads? Yep... Dave Pawson maintains such a site and can be found at http://www.dpawson.co.uk/xsl/index.html
Wrap the first apply-templates into a variable, use your processors node-set() function (see your processors documentation on how to implment this) to convert the result into a node-set and then apply-templates or for-each through the resulting node-set using <xsl:number/> to accomplish the task <xsl:template match="/"> <xsl:variable name="menus" <xsl:apply-templates select="Menus"/> </xsl:variable> <xsl:for-each select="exsl:node-set($menus)"> <!-- change the namespace and syntax for the node-set function above specific to the what the docs tell you for your processor - dont forget to declare the namespace in the xsl:stylesheet element! --> <xsl:number/> .. whatever else you want to output from each node .. you'll obviously need to modify this to fit your .. needs but this is the general idea </xsl:for-each> </xsl:template>
<xsl:template match="Menu"> <xsl:variable name="MenuId" select="@MenuId"/> <xsl:apply-templates select="ancestor-or-self::Menu[@MenuId = $MenuId]" mode="MenuId"> <xsl:with-param name="MenuId" select="$MenuId" /> </xsl:apply-templates> </xsl:template> <xsl:template match="Menu" mode="MenuId"> <xsl:param name="MenuId"/> ... output what you want here ... <xsl:apply-templates select="*[@MenuId = $MenuId]" mode="MenuId"> <xsl:with-param name="MenuId" select="$MenuId"/> </xsl:apply-templates> </xsl:template> Untested, but this is the general idea... Im in the middle of some other code but as soon as I have a chance I will test this and see if there are any blaring mistakes and respond back if yes... Best of luck! <M:D/> :: Saxon.NET general public early beta will be available Tuesday, July 27th :: :: DISCLAIMER: All efforts have been made to ensure a quality beta release :: :: None-the-less, this is an early beta release that should only be used :: :: in test environments for the purpose of testing performance and helping :: :: to locate potential bugs and performance bottlenecks. With this in mind :: :: PLEASE DO NOT CONSIDER THIS RELEASE READY FOR PRODUCTION IMPLEMENTATION! ::
|
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








