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

recursive call of template - how to find parents

Subject: recursive call of template - how to find parents
From: Michael Olszynski <m.olszynski@xxxxxxxxxxxxx>
Date: Wed, 05 Nov 2003 09:55:56 +0100
find parents
Hello,

I go recursively through a template and print the names of the xml-elements. That works fine (thanks for your help in this newsgroup). But now I need to output another attribute with every element, and I need to output this attribute also from all its parents. How can I find out if there´s still a parent left? I give you an example of my xml-File my xslt-code and the desired output.

Thanks a lot


############# The xml - File ############# <topic name="point1" filename="asdf"> <topic name="subpoint1" filename="asdf1"> <topic name="subsubpoint1" filename="asdf2"> <topic name="subsubsubpoint1" filename="asdf3"> </topic> </topic> </topic> <topic name="subpoint2" filename="asdf4"> </topic> </topic> <topic name="point2" filename="asdf5"> </topic> <topic name="point3" filename="asdf6"> </topic> <topic name="point4" filename="asdf7"> </topic>


############## the xsl template #################


   <xsl:template name="sitemap">
       <ul>
           <xsl:for-each select="//homepage/topic">
               <li>
                   <xsl:value-of select="."/>
               </li>
               <ul>
                   <xsl:apply-templates select="topic"/>
               </ul>
           </xsl:for-each>
       </ul>
   </xsl:template>
   <xsl:template match="topic">
       <li>
           <xsl:value-of select="."/>
           <xsl:if test="topic">
               <ul>
                   <xsl:apply-templates select="topic"/>
               </ul>
           </xsl:if>
       </li>
   </xsl:template>


##################### the desired output ###################


<ul xmlns="">
<li>
<a href="asdf">point1
</a>
<ul><li>
<a href="asdf/asdf1">
subpoint1
<ul><li>
<a href="asdf/asdf1/asdf2">subsubpoint1</li>
...... and so on.


So you see, the the <a href=..... is the problem. How can I go up in the recusively called template and always add the filename attribute, starting from the uppper mostt topic element?

So if I´m in subsubsubpoint, I´d like to have the fileanmes beginning from the uppermost topic element:
<a href=asdf/asdf1/asdf2/asdf3>


Thanks a lot Michael



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


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.