xsl-list
[Top] [All Lists]

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

2005-03-09 12:46:15
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 'a´ 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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>