LOL. Thank you so much! That was embarasingly easy once you pointed
out that I should match against the element. So all I needed was
this...
<xsl:template match="dir[@name='dir6']">
<ul>
<xsl:for-each select="ancestor::*">
<li><xsl:value-of select="@name"/></li>
</xsl:for-each>
</ul>
<ul>
<li><xsl:value-of select="@name"/>
<ul>
<xsl:for-each select="./dir">
<li><xsl:value-of select="@name"/></li>
</xsl:for-each>
</ul>
</li>
</ul>
</xsl:template>
It's slightly different to your approach where you suggested
<xsl:apply-templates mode="list-dir"
select="parent::dir/ancestor::dir"/>. Could you tell me what this
does?
Once again thank you. I've been banging my head on this one for too long!
On Tue, Mar 31, 2009 at 5:16 PM, Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
wrote:
> Jim,
>
> If I understand this correctly, you don't actually have to recursively call
> a template. You only have to iterate through (a) ancestor dir elements of
> your parent::dir, and then (2) the parent dir element (and maybe its
> descendants).
>
> The reason I say "maybe" is that the source as offered gives two page6
> pages:
>
> At 11:28 AM 3/31/2009, you wrote:
>>
>> <dir name="dir1" id="x1">
>> <page pname = "page1"></page>
>> <dir name="dir2" id="x2">
>> <page pname = "page2"></page>
>> <dir name="dir3" id="x3">
>> <page pname = "page3"></page>
>> </dir>
>> <dir name="dir4" id="x4">
>> <page pname = "page4"></page>
>> <dir name="dir5" id="x5">
>> <page pname = "page5"></page>
>> <page pname = "page6"></page>
>> <dir name="dir6" id="x6">
>> <page pname = "page6"></page>
>> </dir>
>> </dir>
>> </dir>
>> </dir>
>> </dir>
>
> So we don't know on what basis the dir6 is included in the result you say
> you want.
>
>> The above is a snapshot as it can go down "n" levels. If I'm at page6
>> then my navigation needs to be:-
>>
>> <ul>
>> <li>dir1</li>
>> <li>dir2</li>
>> <li>dir4</li>
>> </ul>
>> <ul>
>> <li>dir5</li>
>> <li>dir6</li>
>> </ul>
>
> In any case, something like this (assuming the second page6 in your stated
> source is erroneous):
>
> <xsl:template match="page6">
> <ul>
> <xsl:apply-templates mode="list-dir"
select="parent::dir/ancestor::dir"/>
> <!-- apply-templates generates output ordered as they are in the source,
> so this will get dir1, dir2, dir4 -->
> </ul>
> <ul>
> <xsl:apply-templates mode="list-dir"
> select="parent::dir/descendant-or-self::dir"/>
> <!-- this gets dir5 (the parent of page6) and dir6 (the dir inside dir5)
> -->
> </ul>
> </xsl:template>
>
> I hope that helps --
> Wendell
>
>
>
> ======================================================================
> Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
> Mulberry Technologies, Inc. http://www.mulberrytech.com
> 17 West Jefferson Street Direct Phone: 301/315-9635
> Suite 207 Phone: 301/315-9631
> Rockville, MD 20850 Fax: 301/315-8285
> ----------------------------------------------------------------------
> Mulberry Technologies: A Consultancy Specializing in SGML and XML
> ======================================================================
|