[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Expanding XML navigation


Subject: Re: [xsl] Expanding XML navigation
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 27 Sep 2004 16:29:32 +0100

<xsl:stylesheet
   version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>

<xsl:output indent="yes"/>


<xsl:template match="/">
 <xsl:apply-templates mode="x" select="/">
  <xsl:with-param name="x" select="'manhattan'"/>
 </xsl:apply-templates>
</xsl:template>


<xsl:template mode="x" match="/|*">
<xsl:param name="x"/>
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:if test="descendant-or-self::page[@name=$x]">
 <xsl:apply-templates mode="x" select="*">
  <xsl:with-param name="x" select="$x"/>
 </xsl:apply-templates>
</xsl:if>
</xsl:copy>
</xsl:template>



</xsl:stylesheet>


produces

$ saxon tree.xml  tree.xsl
<?xml version="1.0" encoding="utf-8"?>
<linkmap>
   <page name="index">
      <page name="about"/>
      <page name="events"/>
      <page name="contact">
         <page name="directions">
            <page name="new-york">
               <page name="manhattan">
                  <page name="uptown"/>
               </page>
               <page name="bronx"/>
            </page>
            <page name="paris"/>
         </page>
      </page>
   </page>
</linkmap>

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________


Current Thread
  • [xsl] Expanding XML navigation
    • Alex - Tue, 21 Sep 2004 13:54:45 +0100
      • <Possible follow-ups>
      • Andrew Welch - Tue, 21 Sep 2004 16:58:09 +0100
      • Alex - Mon, 27 Sep 2004 16:13:46 +0100
        • David Carlisle - Mon, 27 Sep 2004 16:29:32 +0100 <=
      • Alex - Mon, 27 Sep 2004 16:16:13 +0100
      • Andrew Welch - Mon, 27 Sep 2004 16:43:11 +0100
      • Alex - Mon, 27 Sep 2004 17:02:32 +0100