[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Trouble with position!

Subject: RE: Trouble with position!
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 15 Apr 2005 09:07:58 +0100
hilditch kay
When the value of a predicate [X] is an integer, it's a shorthand for
[position()=X]. So E[position()] means E[position()=position()] which is the
same as E[true()], or simply E. Your mistake is in forgetting that the
context changes inside the square brackets. So you need to assign a variable
to the value of position() outside the predicate, and then use the variable
inside the predicate:

<xsl:variable name="pos" select="position">
<xsl:value-of select="x/y/z[$pos]"/>

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Adam J Knight [mailto:adam@xxxxxxxxxxxxxxxxx] 
> Sent: 15 April 2005 03:44
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Trouble with position!
> 
> Hi all,
> 
>  With this xml structure in mind:
>  <dfile>
>   <df_column_names>
>     <df_column name="employee_name" type="hyperlink">Name:</df_column>
>     <df_column name="department" type="text">Department:</df_column>
>     <df_column name="position" type="text">Position:</df_column>
>   </df_column_names>
>   <df_data_row>
>     <data_key>1695</data_key>
>     <df_data>Charles Hilditch</df_data>
>     <df_data>Processing</df_data>
>     <df_data>Mill Supervisor</df_data>
>   </df_data_row>
>  </dfile>
> 
>  I am trying to select the type attribute for a particular 
> df_data element.
>  
>  <xsl:for-each select="./df_data">
>  <xsl:value-of 
> select="/dfile/df_column_names/df_column[position()]/@type"/>
>  </xsl:for-each> 
>  
> My algorithm is simply select the type attribute from df_column whose
> position Is equal to current df_data element being processed.
> 
> I keep getting the type attribute for the first db_column name only.
> 
> Thanx to those who respond.
> 				
> 
> Cheers, 
> Adam 

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.