rnd_nr_gen
rnd_nr_gen

Reputation: 2281

How can I pass external variable with Xidel tool?

I have a XQuery expression stored in a file

(: file process.xq :) 
declare variable $var external;
...

and use it with Xidel.

 xidel  --silent --color=never --xml --xquery "$(< process.xq)" my.xml

How can I pass such external variable?

Upvotes: 0

Views: 190

Answers (2)

Reino
Reino

Reputation: 3443

I'm no XQuery expert, but at least for xidel this is how you declare a variable in a query-file:

declare variable $var := "external";

()

And don't forget the (), or you'll get err:XPST0003: Unexpected query end.

Then to load the query-file:

$ xidel -s --extract-file=process.xq -e '$var'
#or
$ xidel -s -e @process.xq -e '$var'
external

Upvotes: 0

rnd_nr_gen
rnd_nr_gen

Reputation: 2281

it seems be not possible with "external"

but it can be achieved somehow with extra query expression....

xidel  --silent --color=never --xml --xquery "foo := bar" --xquery "$(< process.xq)" my.xml

and just use the $foo as "usual"

(: file process.xq :) 
$foo
...

Upvotes: 0

Related Questions