RE: [xsl] Numbering Consecutive Nodes

Subject: RE: [xsl] Numbering Consecutive Nodes
From: "Mark Grant" <mark.grant@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 31 May 2006 12:52:14 +0100
David,

Thanks for the rapid response - its been a while since I really worked
XSLT with anything more complicated than simple templates.

Your suggestions have worked successfully - one question though - why do
the nodes start numbering from 624 rather than 1?

Best Regards,

Mark Grant

-----Original Message-----
From: David Carlisle [mailto:davidc@xxxxxxxxx]
Sent: 31 May 2006 12:10
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Numbering Consecutive Nodes



	<xsl:template match="PageContent//node()">

I don't think that you want to match _all_ nodes below PageContent This
would include text nodes comments and anything else. If you apply
templates to any text node this template will generate an error as
		<xsl:copy>
will copy the text node but then 	<xsl:attribute name="id">
will try to make an attribute on a text node which obviously isn't
allowed. Change node() to * in the match pattern.

By default xsl:number just counts children of the current parent you
want
<xsl:number level="any"/>

		<xsl:apply-templates
select="PageContent//node()" />

This selects all descendents of the PageContent child of the current
node. However the current node (which is a descendent of PageContent)
has no PageContent child so this will select nothing.

You just want
<xsl:apply-templates/>
here the default behaviour of just processing the child nodes is what
you want. (Lower descendendts will be recursively processed when the
templates matching the child nodes are executed.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread