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

RE: A Counter Variable in XSLT?

Subject: RE: A Counter Variable in XSLT?
From: "Grant Mc Auley" <gmcauley@xxxxxxxxxxx>
Date: Fri, 5 Oct 2001 11:33:35 -0700
grant mc
Thanks folks for your replies.

> But you need
> to say what it is
> you want to do before anyone can show the xslt equivalent)
>

What I want to do:

My stylesheet consists of one template rule.  When there is a
match, I want a line in the output  to say, for example, "Match #
123:", followed by relevant text.  Since I don't know ahead of
time how many matches there will be in the source document,
somehow the stylesheet needs to keep a count.  Something like:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  <xsl:output method="text"/>
  <xsl:template match="/*">
	<xsl:if test="@col">
      Match # n : <!-- n is the nth match, the thing that needs to
be incremented -->
      Collection: "<xsl:value-of select="@col"/>"
      Content: <xsl:value-of select="."/>
      </xsl:if>
  </xsl:template>
</xsl:stylesheet>

>
> You need to unlearn procedural programming! XSLT is a
> declarative,
> functional language.

I am willing!  Just what is meant by "declarative, functional"?

>3. If neither of options 1 or 2 is suitable, you can probably
count what you
>want by using a recursive named template.

Just what is a "recursive named template"?

Thank you for your input,

Grant Mc Auley


 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.