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 November 10th, 2009, 11:01 AM
Authorized User
 
Join Date: Oct 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default storing value in variable

Hi,

I want to declare a variable with file name and path and use that variable in the code. But it is returning the data in variable instead of string which i am assign to variable.

code is below :

Code:
<xsl:variable name="path">

<xsl:value-of select="document('enhanced-newssheets.xml')/./*[@Id=$topic]"></xsl:value-of>
 </xsl:variable>
How can i get the exact string as value in variable ?

Thanks for your help

Hari
 
Old November 10th, 2009, 11:08 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

'data in variable' and 'string I am assigning to variable' mean the same thing to me.

<xsl:value-of select="$path"/> will output whatever is in the variable.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 10th, 2009, 11:29 AM
Authorized User
 
Join Date: Oct 2009
Posts: 15
Thanks: 3
Thanked 0 Times in 0 Posts
Default

What i mean is i want the below string in the variable.

'document('enhanced-newssheets.xml')/./*[@Id=$topic]'

but instead its returning data from the xml document.
 
Old November 10th, 2009, 11:37 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I can't see why you would, but just do the following:

<xsl:variable name="path">document('enhanced-newssheets.xml')/./*[@Id=$topic]</xsl:value-of>
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old November 10th, 2009, 12:48 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Standard XSLT doesn't allow you to construct XPath expressions as strings and then evaluate them dynamically.

Many products have an extension that does this: look for saxon:evaluate(), xalan:evaluate(), dyn:evaluate() or similar functions.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing HTML in a Variable Stevenm122084 XSLT 1 February 22nd, 2008 03:51 PM
Storing data to a variable Mikect VB Databases Basics 1 April 16th, 2007 01:53 PM
storing Javascript variable to ASP variable rupen Classic ASP Basics 5 April 10th, 2007 07:06 AM
Storing an include in a variable trufla Beginning PHP 1 May 21st, 2006 10:52 PM
Getting oracle value and storing in xslt variable msj_vijay XSLT 0 December 29th, 2005 04:21 AM





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