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

RE: RE: XSL-List Digest V4 #1168

Subject: RE: RE: XSL-List Digest V4 #1168
From: "Conal Tuohy" <conalt@xxxxxxxxxxxxxxx>
Date: Thu, 20 Mar 2003 12:56:10 +1200
maketreepath
Walter Crockett wrote:

> 	I'm updating an old stylesheet that still works, but it calls 
> xmlns:xsl="http://www.w3.org/TR/WD-xsl" instead of the modern version.
> 
> This seems to prevent me from using simple functions like position().
> 
> When I change to http://www.w3.org/1999/XSL/Transform, it 
> breaks because it
> uses the now-defunct xsl:eval.
> 
> <xsl:if test="@Level">  
>      <xsl:eval>makeTreePath(this)</xsl:eval>
> </xsl:if>
> 
> It needs this to make a nice tree in HTML:
> 
>  <xsl:script>
>    <![CDATA[
>       function makeTreePath(e)
>       {
>           var depthChar="|---";
>           var result="";
>           var i; 
>           var j = e.getAttribute("Level");         
> 
>           for(i = 0;i < j;i++){
>               result += depthChar;               
>           }
>           
>           return result;
>       } 
>    ]]>
>    </xsl:script>

This is a FAQ: http://www.dpawson.co.uk/xsl/sect2/repetition.html

Replace the javascript function with a named template like this:

<xsl:template name="makeTreePath">
  <xsl:param name="n"/>
  <xsl:if test="number($n) > 0">
    <xsl:text>|---</xsl:text>
    <xsl:call-template name="makeTreePath">
      <xsl:with-param name="n" select="number($n) - 1"/>
    </xsl:call-template>
  </xsl:if>
</xsl:template>

and call it like this:

<xsl:if test="@Level">  
      <xsl:call-template name="makeTreePath">
		<xsl:with-param name="n" select="@Level"/>
	</xsl:call-template>
</xsl:if>

Cheers!

Con

 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.