Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2008, 12:58 PM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Using string parameter as an XPath

I need to be able to use my parameter to specify an XPath in one of my templates.

EX:

sample input: //boxes

<xsl:param name="inPath"/>

<xsl:template match="$inPath">
..........other code........
</xsl:template>


How do I convert my string input into an XPath for that kind of use. Right now it just gives me an error.
 
Old August 14th, 2008, 04:10 PM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

There is no facility in standard XSLT to do this.

You could do something like <xsl:template match="*[name()=$inPath"> if $inPath was 'boxes'.

/- Sam Judson : Wrox Technical Editor -/
 
Old August 15th, 2008, 09:41 AM
Authorized User
 
Join Date: Apr 2008
Posts: 70
Thanks: 17
Thanked 1 Time in 1 Post
Send a message via Yahoo to iceandrews
Default

What kind of processor are you running your XSLT and at what version ?

If you're running Saxon, you could make use of the "Extension Functions".

Between the following:
saxon:evaluate()
saxon:expression()
saxon:eval()

You should be able to manipulate an incoming string appropriately to use as an XPath. For full documentation on these functions see the official site.
http://www.saxonica.com/documentatio...functions.html

Im' not as familiar with the other processors available and specific functions they may have, but their may be something similar.

 
Old August 15th, 2008, 09:55 AM
Registered User
 
Join Date: Aug 2008
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using the Saxon processor and the function you provided did the trick! Thanks!






Similar Threads
Thread Thread Starter Forum Replies Last Post
String as Parameter ndr1977 .NET Web Services 2 June 10th, 2008 03:23 AM
String xsl:param as XPath expression Vx XSLT 4 September 5th, 2006 10:18 AM
Syntax help with string-length and XPath EstherMStrom XSLT 1 February 9th, 2005 08:02 PM
XPath: String functions question. pupu79 XSLT 4 January 10th, 2005 03:00 PM
can we do string manipulation on a parameter? Feng BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 July 31st, 2004 11:20 AM





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