[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL resources - Flat to hierarchy - Common ancestors

Subject: XSL resources - Flat to hierarchy - Common ancestors
From: "Ben Simkins" <bsimkins@xxxxxxxxxx>
Date: Mon, 26 Jul 2004 16:55:38 +0200
xsl ancestors
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?

2. Transforming 'flat' structures to hierarchies:
I've adapted a stylesheet found in this list, for creating the hierarchy
of this:
<Menus>
  <Menu MenuId="58" MenuName="LeftMenu"/>
  <Menu MenuId="1" MenuParentId="58" MenuName="Home"/>
  <Menu MenuId="60" MenuParentId="1" MenuName="About us/>
  ...etc
</Menus>

The xsl looks like this:
<xsl:template match="/">
	<xsl:apply-templates select="Menus"/>
</xsl:template>

<xsl:template match="Menus">
  <xsl:copy>
    <xsl:apply-templates select="Menu[not(@MenuParentId)]">
    </xsl:apply-templates>
  </xsl:copy>
</xsl:template>

<xsl:template match="Menu">
  <xsl:copy>
  	<xsl:copy-of select="@*"/>
  	<xsl:apply-templates select="../Menu[@MenuParentId =
current()/@MenuId]"/>
  </xsl:copy>
</xsl:template>

Question: is there any way of also adding the numbering (<xsl:number
level="multiple" format="1.1"/>) directly, or do I have to run the
output through a second stylesheet?

3. Given the hierarchical output from 2, I would like to extract all
nodes which are children of any of the ancestors of the node with a
given MenuId (including that node itself)
Expressed otherwise: the children, siblings, ancestors, uncles and
great-uncles, great-great-uncles (etc) of the given node.
Expressed otherwise: all Menus where MenuParentId IN (MenuIds of a given
node and all of its ancestors)

Many thanks for any answers received

Ben Simkins

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.