[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Using a string parameter as path expression

Michael Kay mhk at mhk.me.uk
Mon Feb 14 18:52:49 PST 2005


path expression
You can't do this in standard XQuery. The ability to take a path expression
and interpret it at run-time is provided in some products by a vendor
extension function: in Saxon this is called saxon:evaluate(). The precise
rules for how it works (specifically, the rules for establishing the static
and dynamic context of the expression) will vary from one product to
another. You need to take particular care if the path expression contains
namespace prefixes.
 
You would typically write
 
return doc("sample.xml")/saxon:evaluate($path)
 
Michael Kay
http://www.saxonica.com/


  _____  

From: http://xquery.com/mailman/listinfo/talk [mailto:http://xquery.com/mailman/listinfo/talk] On Behalf Of
Mathias Seifert
Sent: 14 February 2005 18:31
To: http://xquery.com/mailman/listinfo/talk
Subject:  Using a string parameter as path expression



Hello, 

I have a question for a rather simple task which I couldn't find any
solution to. What I want to have is a function that takes an xpath as string
parameter and then evaluates this xpath on a document. This could look
something like the following: 

declare function local:evalPath($path as xs:string) as node() 
{ 
        let $a := doc("sample.xml")/$path 
        return $a 
} 

Unfortunately I couldn't get this simple function to work, so my question
now is: Is it possible with xquery at all to have a variable as the path
expression of a for/let clause? And if so, how? 

Thanks in advance. 

Mathias


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://xquery.com/pipermail/talk/attachments/20050214/9edfe639/attachment.htm


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.