xsl-list
[Top] [All Lists]

RE: Expanding XML navigation

2004-09-27 09:02:32


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(_at_)piper-group(_dot_)com]
Sent: 27 September 2004 16:43
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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::*[(_at_)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?

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--



<Prev in Thread] Current Thread [Next in Thread>