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

RE: Putting parameter into XPATH expression

Subject: RE: Putting parameter into XPATH expression
From: "Michael Kay" <mhkay@xxxxxxxxxxxx>
Date: Fri, 22 Jun 2001 23:27:00 +0100
xpath position parameter
The simplest way is to make $position a number by writing

<xsl:with-param name="position" select="1"/>

instead of

<xsl:with-param name="position" select="'1'"/>

which makes it a string.

Or you could force it to a number: a/b[number($position)],

or use a boolean predicate: a/b[position()=$position]

Mike Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of MacEwan,
> James (Information Services)
> Sent: 22 June 2001 20:24
> To: 'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'
> Subject:  Putting parameter into XPATH expression
> 
> 
> Hi,
> 
> In the code extract below, I always get the result 
> "OneOneOne" instead of
> "OneTwoThree" which I am expecting.
> 
> I found a work around (based on my previous experience 
> writing compilers)
> that gets XSL processor to do what I want: "<xsl:value-of
> select="a/b[$Position + 0 ]/c"/>"
> 
> Can someone tell me a better (more correct) way to do this?
> 
> XML ------------------
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <a>
>   <b>	<c>One</c> </b>
>   <b>	<c>Two</c> </b>
>   <b>	<c>Three</c> </b>
> </a>
>   
> 
> In my XSL, I do the following to write out the words One, Two 
> and Three
> ---------------
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
> 
> <xsl:output method="text"/>
> 
> <xsl:template match="/">
> 		 		<xsl:call-template name="Jump">
> 				    <xsl:with-param name="Position"
> select="'1'"/>
> 				</xsl:call-template>
> 
> 		 		<xsl:call-template name="Jump">
> 				    <xsl:with-param name="Position"
> select="'2'"/>
> 				</xsl:call-template>
> 
> 		 		<xsl:call-template name="Jump">
> 				    <xsl:with-param name="Position"
> select="'3'"/>
> 				</xsl:call-template>
> </xsl:template>
> 
> <xsl:template name="Jump">
> 		<xsl:param name="Position"/>
> 
> 	<xsl:value-of select="a/b[$Position ]/c"/>
> 
> </xsl:template>
> 
> Thanks,
> 
> 
> -James MacEwan
> Software Developer
> Investors Group Inc.
> mailto:James.MacEwan@xxxxxxxxxxxxxxxxxx
> v: (204) 956-8515
> f: (204) 943-3540
> 
> "I don't know, lad. It's like no cheese I've ever tasted." -- Wallace
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.