On 2008 Aug 18, at 14:21, henry human wrote:
I tried with the FAQ and i understood it so as i am
witing the code snippet bellow!
Here is the sample.
In this loop it should turns 2 times because there are
2 sections and than displays the
author names in:
(this is the array: [(_at_)type='author'][position()])
This account doesn't really match what the sample XSLT is trying to
do, but I think I understand what you're after. Consider the following:
% cat hh.xml
<element type="author">Author number 1</element>
<element type="author">Author number 2</element>
<element type="section">section 1</element>
<element type="section">section 2</element>
% cat hh.xslt
% xsltproc hh.xslt hh.xml
<p>Element: section 1</p>
<p>Element: section 2</p>
(Did you want something to happen to the <author> elements? It's not
at all clear)
I think that your fundamental problem is that you're thinking of
'arrays' and 'indexes' in a language where this isn't natural. You
probably don't need to use position() at all.
In XSL, using for-each is almost always the wrong (or at least an
unnatural) way of doing things. Of course, 'wrong' here is a bit of
an exaggeration, but it does seem to be true that the people who use
xsl:for-each the most are those new to the language.
XSL is a templating language, specialised for processing trees of
elements, and that means that implicit loop within the xsl:apply-
templates is usually the most suited to the job.
Norman Gray : http://nxg.me.uk
Physics and Astronomy, University of Leicester
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>