RE: [xsl] Can't identify last ancestor node

Subject: RE: [xsl] Can't identify last ancestor node
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Tue, 28 Jun 2005 18:19:10 +0000
Mat, you do want last() to identify the last menu. For example, with your input (below), this XSL:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="xml" indent="yes"/>


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

   <xsl:template match="menu[not(*) and position() = last()]">
       <xsl:copy>
           <xsl:copy-of select="@*"/>
           <xsl:attribute name="last">1</xsl:attribute>
       </xsl:copy>
   </xsl:template>

</xsl:stylesheet>

Produces:

<?xml version="1.0" encoding="UTF-8"?>
<menudata>
    <menu name="link1">
         <menu name="link1a"/>
         <menu name="link1b"/>
         <menu name="link1c" last="1"/>
    </menu>
    <menu name="link2">
         <menu name="link2a"/>
         <menu name="link2b"/>
         <menu name="link2c" last="1"/>
    </menu>
</menudata>

--A

From: Mat Bergman <matbergman@xxxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Can't identify last ancestor node
Date: Tue, 28 Jun 2005 09:20:23 -0700 (PDT)

This is close to what I need, but I need to be more
clear. In this case, the context node is
/menudata/menu/menu. I want to apply unique output for
the last <menu> nodes in /menudata/menu/menu. For
instance:

<menudata>
     <menu name="link1">
          <menu name="link1a"/>
          <menu name="link1b"/>
          <menu name="link1c"/>
     </menu>
     <menu name="link2">
          <menu name="link2a"/>
          <menu name="link2b"/>
          <menu name="link2c"/>
     </menu>
</menudata>

_________________________________________________________________
Dont just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Current Thread