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

xsl variable, param: need references to full tree

Subject: xsl variable, param: need references to full tree
From: Simeon Ott <sot@xxxxxx>
Date: Thu, 22 Jan 2004 10:22:36 +0100
xsl variable param
i've got the following xml as an example tree, and need to go through the tree, level based!:
as an example: "all title elements with level 0" should give me the element "title" with its childs commented as "element 1"
a 2nd example: "all title elements with level 1" should give me the elements "title" with its childs commented as "element 2" and "element 3"


<tablehead>
  <title> <!-- this is element 1 -->
    <value>Saldo letzter Abschluss</value>
    <cssclass>head</cssclass>
    <colwidth>250</colwidth>
    <visibility>visible</visibility>
    <layout>fixed</layout>
    <subtitles>
      <title> <!-- this is element 2 -->
        <value>Soll</value>
        <cssclass>head</cssclass>
        <colwidth>125</colwidth>
        <sortorder>no</sortorder>
      </title>
      <title> <!-- this is element 3 -->
        <value>Haben</value>
        <cssclass>head</cssclass>
        <colwidth>125</colwidth>
        <sortorder>no</sortorder>
      </title>
    </subtitles>
  </title>
</tablehead>

the following stylesheet do that (nearly) correct:

- call to template:
<xsl:call-template name="jumptolevel" >
  <!-- specify the level -->
  <xsl:with-param name="level" select="1" />
  <!-- root titles -->
  <xsl:with-param name="elements" select="/tablehead/title" />
</xsl:call-template>

- template itself:
<xsl:template name="jumptolevel">
  <xsl:param name="i" select="0" />
  <xsl:param name="level" select="0" />
  <xsl:param name="elements" />

<xsl:choose>
<xsl:when test="$i &lt; $level">
<xsl:call-template name="jumptolevel">
<xsl:with-param name="i" select="$i + 1" />
<xsl:with-param name="level" select="$level" />
<xsl:with-param name="elements" select="$elements/subtitles/title" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:copy-of select="$elements" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>


the problem is, i need the result of the template "jumptolevel" as a reference in the whole tree.
when i call the template as followed


<xsl:variable name="test">
  <xsl:call-template name="jumptolevel" >
     <!-- specify the level -->
    <xsl:with-param name="level" select="1" />
     <!-- root titles -->
    <xsl:with-param name="elements" select="/tablehead/title" />
  </xsl:call-template>
</xsl:variable>
<xsl:value-of select="name($test/..)" />

i want to have "subtitles" displayed!
the result should give me also the parent nodes, how do i do that? or what i did wrong?


thanks in advance (sorry, for my bad english, i'm swiss ;)
jimmy

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.