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

Re: How to determine the 'first' time a template has b

Subject: Re: How to determine the 'first' time a template has been
From: Dan Diebolt <dandiebolt@xxxxxxxxx>
Date: Tue, 20 Mar 2001 07:05:53 -0800 (PST)
xsl number first time
call-template does not support a mode attribute. I am a bit hard 
pressed to understand why you would need to detect the first use of 
call-template - especially if your are using it within xsl-variable. 

In my usage of XSLT, I often have to do something before 
processing the first node of a node set (kick out introductory 
text or a table header) or perhaps with the first/last node itself. 
You can flag the first node in a node set by several methods:

File: FirstTimeTemplateCalled.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet type="text/xsl" href="FirstTimeTemplateCalled.xsl"?>
<root>
 <item>10</item>
 <item>20</item>
 <item>30</item>
</root>

file: FirstTimeTemplateCalled.xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:template match="/">
  <xsl:apply-templates select="root"/>
 </xsl:template>
 <xsl:template match="root">
  start processing items.<br/>
  <xsl:apply-templates select="item"/>
  end processing items.<br/>
 </xsl:template>
 <xsl:template match="item">
  <xsl:variable name="i1"><xsl:number/></xsl:variable>
  <xsl:variable name="i2" select="position()"/>
  i1=<xsl:value-of select="$i1"/>
  i2=<xsl:value-of select="$i2"/>
  <xsl:if test="$i1=1">- i1=1 indicates first element</xsl:if>
  <xsl:if test="$i2=1">- i2=1 indicates first element</xsl:if>
  <br/>
 </xsl:template>
</xsl:stylesheet>
      





__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

 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.