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

Recursive selection, elegantly

Subject: Recursive selection, elegantly
From: "Stephen Tredrea" <stephen.tredrea@xxxxxxxxxxxxx>
Date: Sun, 6 Jun 2004 09:32:32 +0200
recursive selection
Any suggestion on getting this to work? I can do it in four steps but not in
three as attempted here!

Thanks, Stephen

XML (snippet):

  <menu ref="main_menu">
    <item resource="/" />
    <item resource="/who_we_are" />
    <item resource="/contact_us" />
    <item resource="/disclaimer" />
  </menu>

  <page about="/">
    <name>Home</name>
  </page>

  <page about="/who_we_are">
    <name>About us</name>
  </page>

  ...etc...

XSL (snippet):

  <xsl:template match="/">
    <xsl:apply-templates select="//menu[@ref='main_menu'" mode="main_menu"
/>
  </xsl:template>

  <xsl:template match="menu" mode="main_menu">
    <table>
    <tr>
      <xsl:apply-templates select="//*[@about = item/resource]"
mode="menu_item" />
    </tr>
    </table>
  </xsl:template>

  <xsl:template match="*" mode="menu_item">
    <td>
      <xsl:element name="a">
        <xsl:attribute name="href"><xsl:value-of select="@about"
/></xsl:attribute>
        <xsl:value-of select="name" />
      </xsl:element>
    </td>
  </xsl:template>

Required HTML:

  <table>
  <tr>
    <td><a href="/">Home</a></td>
    <td><a href="/who_we_are">About us</a></td>
    ...etc...
  </tr>
  </table>


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.