Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > position() doesn't return expected value

Thread Tools

position() doesn't return expected value

Posts: n/a
Hi again,

still working on my xslt program and I ran into another problem. There is a
file which a contains the following structure:


When I am in a "dict" tag I want to get the value from the key before it,
because they belong to eachother.. (don't ask me why it's constructed like
this, wasn't my work) Now I wrote the following code which should do the

<xsl:template match="plist/dict">

<xsl:template name="track">

Only, once pos has gained a value, it doesn't seem to get a new value in the
next round of the "for-each" loop.. is this a bug or am I making a mistake
in my thinking? Any help would be appreciated!

Thanks in advance,

Reply With Quote
Peter Flynn
Posts: n/a
What I just said. To find the element position, count the preceding
siblings of the same name, eg

<xsl:if test="count(preceding-sibling::dict)=0">

means "this is the first dict child of its parent".

Personally I would have called the existing function node-position()
and kept position() to mean what it always meant before: position
within the elements; but I think the design team assumed everyone
would be processing without a DTD or Schema, and would therefore
not be handling only element nodes. But that's life.


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Expected expression before return(Error) vaysagekv C Programming 2 07-11-2010 04:11 PM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
getting return value from function without return statement. Seong-Kook Shin C Programming 1 06-18-2004 08:19 AM
Newbie again: position() doesn't return expected value Yereth XML 2 01-20-2004 11:34 AM
Return a return value from Perl to Javascript PvdK Perl 0 07-24-2003 09:20 AM