473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

position() doesn't return expected value

Hi again,

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

<key>1</key>
<dict>
********...
</dict>
<key>2</key>
<dict>
********..
</dict>

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
job:

<xsl:template match="plist/dict">
********<xsl:element*name="playlist">
****************<xsl:for-each*select="child::dict/dict">
************************<xsl:call-template*name="track"/>
****************</xsl:for-each>
********</xsl:element>
</xsl:template>

<xsl:template name="track">
********<xsl:element*name="track">
****************<xsl:variable*name="pos"*select="p osition()"/>
****************<xsl:apply-templates*select="preceding-sibling::key[position()
$pos]"/>
****************<xsl:for-each*select="child::key">
************************<xsl:call-template*name="key_value"/>
****************</xsl:for-each>
********</xsl:element>
</xsl:template>

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,

Yereth
Jul 20 '05 #1
1 1658
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.

///Peter

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: BrassWorld | last post by:
Howdy, I know how to tell a DIV with a vertical scroll bar how far to scroll: document.getElementById( 'myDIV' ).scrollTop += 40; However, under certain conditions, 'myDIV' is hidden. Upon...
4
by: ojorus | last post by:
Hi! I just wonder how I can save a page's scroll position with javascript. (i'm not a javascript developer) I have a PHP-page with two columns; the left contains a lot of thumbnails, and the right...
2
by: Tony Johansson | last post by:
Hello Experts! I have some class definition and a main below. This is a strange problem. When cout is executing in the for loop below locating in main I get this print out on the screen Bird...
1
by: Paul | last post by:
Hi all, I am making a DirectInput application wich must report correctly the cursor position in windowed mode (it means it has to be the same as Microsoft Window´s cursor position). First of...
6
by: meh | last post by:
I can figure out the total number of nodes in a given tree but what I'd like to know is what is the Selected Nodes relationship to the entire tree i.e This is node n out of nnn nodes. In most of...
1
by: truedecembr | last post by:
Hi everyone, I am brand new to Java and not really even sure what I'm doing... I'm supposed to be writing a Timer class that is part of a stop watch application, and it seems to me that the program...
9
by: sunita jadhav | last post by:
my question is if i type in html textbox on key press event suppose i type 12345 values in textbox then i delete or edit any value of text box suppose i edit 3 and i insert the value 6 at 3 but i...
7
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
I need to emulate the missing "maxlegth" attribute in "textarea" fields but all my Google searches either lead to obsolete scripts that overwrite the "value" property (thus losing caret position)...
14
by: Rafe | last post by:
Hi, I've encountered a problem which is making debugging less obvious than it should be. The @property decorator doesn't always raise exceptions. It seems like it is bound to the class but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.