RE: [xsl] Expanding XML navigation

Subject: RE: [xsl] Expanding XML navigation
From: "Alex" <alex.scott@xxxxxxxxxxxxxx>
Date: Mon, 27 Sep 2004 17:02:32 +0100
Yes!!!

I have tried it out with both the code which you posted, and the code which
David posted, so thank you both very much.

Alex.




-----Original Message-----
From: Andrew Welch [mailto:ajwelch@xxxxxxxxxxxxxxx]
Sent: 27 September 2004 16:43
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Expanding XML navigation



This variation of the identity template should do what you need:

<xsl:param name="pageName" select="'manhattan'"/>

<xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:copy-of select="@*"/>
      <xsl:if test="descendant-or-self::*[@name = $pageName]">
        <xsl:apply-templates select="node()"/>
      </xsl:if>
    </xsl:copy>
</xsl:template>

It basically will output the current node, then only continue processing
it's children if a descendent of the current node has an attribute with
the required attribute.  It's not that efficient as it walks the
descendant axis for every node, but if your tree isn't that deep it
shouldn't be too bad.

cheers
andrew

> I am still stuck with this one.
> I just want an expanding list.
>
> Using the Identity transform I get that I can list my whole
> tree, and remove nodes from it: This is the entire tree:
>
> <linkmap>
> <page name="index">
>     <page name="about">
>       <page name="history"/>
>     </page>
>     <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 name="left-bank"/>
>           <page name="right-bank"/>
>         </page>
>       </page>
>      </page>
> </page>
> </linkmap>
>
> If am currently on the Manhattan page,
> Then I just want to show:
> 1)the root nodes about-events-contacts
> 2)As I know that current node is Manhattan I want to find its
> root node which is contact. 3)I then want to show the
> children of contact. 4)I then want to show all the
> descendants of the child of contact which is also the
> ancestor of manhattan down to the children of manhattan.
>
> The result tree should look something like this below:
>
>
>
> <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>
> </page>
> </linkmap>
>
>
> Would it be easier for me to use a process of elimination as
> andrew has suggested or a process of construction?

Current Thread