Re: [xsl] The right way to count from inside a match template

Subject: Re: [xsl] The right way to count from inside a match template
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 09 Mar 2005 14:46:15 -0500
Hi nutdev,

At 01:59 PM 3/9/2005, you wrote:
I have an xsl which is something like this:

<root>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
<a><b>lots of stuff</b></a>
</root>

and I have a template

<xsl:template match="a">

<!--Show which element I on using-->

<!--display lots of stuff-->

</xsl:template>

For the <!--Show which element I on using--> I am trying various
different combinations
of <xsl:number value="something">

Take the @value attribute off and see what happens. You do not want to provide a value to the xsl:number instruction; without it, it will calculate a value on its own (which is what you want).

Any good XSLT reference book will tell you what the @value, @count, @level
and @format attributes on xsl:number will do, but from your description it
appears you want the default behavior.

I have tried counting preceding siblings, position and several other
things, and I only ever get
a 1.

We'd have to see a little more before we could diagnose why that was happening.

I would be really grateful if you could tell me What is the right way to
show 1,2,3,4,5 and then contents of each 'a4 element within the
template.

D'you know how to apply templates?


<xsl:template match="a">
  <xsl:number format="1 "/>
  <xsl:apply-templates/>
</xsl:template>

Cheers,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================

Current Thread