On 2005-06-09 13:33:08 -0400, Rolando Isidoro <[EMAIL PROTECTED]> said:

Hi Eric, thank you for your answer, I've tried some combinations of the tests you sent, but failed to get the result I expected, which I'll try to put in words and some diagrams:

(1) projects            <- menuitem-selected, shows only the direct child nodes
       >> former
       >> undergoing

(2) projects
       >> former
>> undergoing <- menuitem-selected, shows direct child nodes and preceding and following siblings
          >> u1
          >> u2
          >> ...

(3) projects
       >> former
>> f1 <- menuitem-selected, shows direct child nodes and parent's preceding and following siblings
           >> f2
           >> ...
       >> undergoing

I solved (1) by adding this condition:
    <xsl:when test="parent::nav:[EMAIL PROTECTED] = 'true']">
       <xsl:call-template name="item"/>
    </xsl:when>

I solved (2) by adding this condition:
<xsl:when test="(preceding-sibling::nav:[EMAIL PROTECTED] = 'true']) or (following-sibling::nav:[EMAIL PROTECTED] = 'true'])">
       <xsl:call-template name="item"/>
    </xsl:when>

I couldn't figure out how to solve 3 since I'm not a very experienced XPath user. I know is more of an XPath issue rather than Lenya, but could you give a hand with this?

Thanks once again, regards,
Rolando

I did something similar. It uses ULs instead of the DIVs in the default pub and only shows children beneath the currently select tab.

So if you have tabs:

Home | One | Two | Three

And the current document 'ii' is under 'One' you might have something like this:

One
- A
- B
-- i
-- ii <-- selected
- C


The complete menu.xsl is below.

        Sean

<?xml version="1.0" encoding="UTF-8" ?>
<!--
 Copyright 1999-2004 The Apache Software Foundation

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->

<!-- $Id: menu.xsl 55566 2004-10-26 03:53:08Z gregor $ -->

<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
   xmlns:nav="http://apache.org/cocoon/lenya/navigation/1.0";
   xmlns="http://www.w3.org/1999/xhtml";
   exclude-result-prefixes="nav"
   >
<xsl:template match="nav:site">
 <div id="menu">
   <xsl:apply-templates select="nav:node"/>
 </div>
</xsl:template>

<!--
<xsl:template match="nav:[EMAIL PROTECTED] = 'false']"/>
-->

<xsl:template match="nav:node">

          <xsl:if test="descendant-or-self::nav:[EMAIL PROTECTED] = 'true']">
           <h4><xsl:apply-templates select="nav:label"/></h4>
                <xsl:call-template name="list"/>
</xsl:if>
</xsl:template>

<xsl:template name="list">
        <ul>
          <xsl:for-each select="child::nav:node">
                <xsl:call-template name="item"/>
          </xsl:for-each>
        </ul>
</xsl:template>

<xsl:template name="item">
   <xsl:choose>
     <xsl:when test="@current = 'true'">
       <xsl:call-template name="item-selected"/>
     </xsl:when>
     <xsl:otherwise>
       <xsl:call-template name="item-default"/>
     </xsl:otherwise>
   </xsl:choose>
</xsl:template>


<xsl:template name="item-default">
   <li><a href="[EMAIL PROTECTED]"><xsl:apply-templates select="nav:label"/></a>
                <xsl:if test="descendant-or-self::nav:[EMAIL PROTECTED] = 
'true']">
                   <xsl:call-template name="list"/>
                </xsl:if>
   </li>
</xsl:template>
<xsl:template name="item-selected">
   <li class="selected"><xsl:apply-templates select="nav:label"/>
   <xsl:call-template name="list"/>
   </li>
</xsl:template>


<xsl:template match="nav:label">
 <xsl:value-of select="."/>
</xsl:template>
<xsl:template match="@*|node()">
 <xsl:copy>
   <xsl:apply-templates select="@*|node()"/>
 </xsl:copy>
</xsl:template>


</xsl:stylesheet>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to