[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Can't identify last ancestor node

Subject: RE: Can't identify last ancestor node
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Tue, 28 Jun 2005 18:19:10 +0000
xsl ancestor node
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.