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

Re: document() function using variable

Subject: Re: document() function using variable
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 14 May 2007 11:50:46 +0200
Re:  document() function using variable
Vaduvoiu Tiberiu wrote:
Simple question to the point:

document('/folder/folder2/file.xml')/title work

but if I have a parameter "nm" with the value of "file" or a variable with the name of "nm" with the value of "file" then

document('/folder/folder2/$nm.xml')/title doesn't work. Why doesn't it work?? I tried googling "document() using parameter" and other ways but I didn't find anything usefull. Anyone can help me out?? 10x

'/folder/folder2/$nm.xml' is a string containing the '$' dollar sign (and hence, searches for a file with the name '$nm.xml', which is apparently not what you want). Luckily, it is not interpreted as a variable reference! How would the compiler know whether your variable is $nm, $nm.xml or even something else? You probably want to use concat, or something similar, which concatenates strings):


document(concat('/folder/folder2/', $nm, '.xml'))/title

Btw, some help for google: use the term "xslt how to concatenate strings" (without quotes). The first hits explain what you need to know.

Cheers,
-- Abel Braaksma

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-2011 All Rights Reserved.