Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 20th, 2006, 05:23 PM
Authorized User
 
Join Date: Apr 2006
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL Params inside When Test

Hi, i have the following when statement, inside the test I'm tring to use '$rowNo' parameter inside the string, because I'm using a recursive loop. Everything else works great but I want to be able to join, 1, 2 & 3 together.

1) <xsl:when test="contains(substring(//helper/row/row
2) $rowNo
3) /text(), $helperNo,2), '--')">

<xsl:when test="contains(substring(//helper/row/row$rowNo/text(), $helperNo,2), '--')">

I've tried concat (dont work, comes up with NaN2 in the output):

<xsl:when test="contains(concat(substring(//helper/row/row,$rowNo,/text(), $helperNo,2)), '--')">

-----------------------------------------
Input:
//helper/row

<row num="1">
<row1>01020304--0506070809--10111213</row1>
<row2>14--------15----------16------</row2>
<row3>17------18------------19------</row3>
<row4>20------21--------2223--------</row4>
<row5>------24--------25------------</row5>
</row>


------------------

Any help much much appreicated.


Tried the following too:

<xsl:variable name="starter" select="'substring(//helper/row/row'" />
<xsl:variable name="finisher" select="'/text()'" />
<xsl:variable name="finisher2" select="',$helperNo,2)'" />

...
<xsl:value-of select="$starter+$rowNo+$finisher+$finisher2"/>
...


Doesn't work either! :(

PLEASE PLEASE PLEASE - Just want to know if this is possible really (and how if available).

Thank you.

Reply With Quote
  #2 (permalink)  
Old April 21st, 2006, 04:20 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Variables in XSLT work like in languages such as C, Java, or Javscript: they can be used anywhere you can use a *value*. They don't work like variables in a shell-script or other macro language, where they can replace any part of the text of an expression.

Using element names like <row1>, <row2> is pretty poor XML design. This is what attributes are designed for: <row nr="2">. But if you're saddled with this kind of structure, you can use

.../*[name() = concat('row', $rownr)]/...

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old April 21st, 2006, 04:22 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Again you are making the mistake of thinking that a variable holds a piece of XPath expression text. It doesn't - it holds a value. Use variables only where you might use say a number 2 or a string literal 'fred'.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote
  #4 (permalink)  
Old April 21st, 2006, 05:45 AM
Authorized User
 
Join Date: Apr 2006
Location: , , United Kingdom.
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael, much appreciated.

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:when test - comparison problem pelicanPaul XSLT 1 June 29th, 2007 04:45 AM
Sorting a xsl:if test="position()" charmaigne XSLT 2 April 12th, 2006 04:42 AM
XSL Test tclancy XSLT 2 February 3rd, 2006 02:49 PM
<xsl:if test="" Question kwilliams XSLT 2 August 9th, 2005 08:30 AM
Using xsl:if test attributes rdavisiii XSLT 4 November 9th, 2004 12:24 AM



All times are GMT -4. The time now is 09:06 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.