Re: [xsl] sequential numbering in xslt

Subject: Re: [xsl] sequential numbering in xslt
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 4 Jan 2010 17:32:16 GMT
> Also, position() does not increment is that correct? Will it not be
> always 1?

if you are processing a sequence of items then position() returns the
number of the item in the current sequence.

Ken's suggestion was that if (as is usually the case) you are starting
with a sequence of documents, then position() will return the number of
the current document.

>  I use saxon to read a directory of files,

if you mean using the built in "all files in a directory" feature, then
(I think) essentially you are running a separate transform on each input
with no connection between them, so instead use the collection()
function (perhaps with one of the saxon-specific query uri forms to refer
to all the xml files in the directory) then iterate over the collection
with
<xsl:for-each select="collection(.......)">
this is document: <xsl:value-of select="position()"/>



> failed because of the xsl:variable limitations.
Declarative programming languages in which variables hold values (rather
than memory locations) have the same expressive power as imperative
languages, so it's misleading to call this a limitation.

David

Current Thread