2

I'm having trouble passing arguments to xquery in powershell. Works fine in cygwin. What's the way to do this?

@edit:

Here's an example of how I've been doing this in bash, where 'xquery' is my alias for the saxon xquery engine:

xquery -s:input.xml -q:query.xquery -o:output

If I attempt the same thing in powershell, I get:

"No query file name"

I'm 99% sure this is a problem of powershell syntax, IE, I'm not passing parameters to xquery with the right syntax.

1
  • Why don't you share some more details of your trouble, rather than leaving us guessing. What exactly are you trying to pass, and what results do you get? It might be a good idea to reduce the problem to a minimum reproduction and showing that.
    – Gunther
    Commented Apr 3, 2011 at 11:21

1 Answer 1

2

How was your xquery command defined?

The following should work:

function xquery {java net.sf.saxon.Query $args}
xquery "-s:input.xml" "-q:query.xquery" "-o:output"

Or, without the function,

java net.sf.saxon.Query -s:input.xml -q:query.xquery -o:output
2
  • YUP that did the trick Gunther. I had to redefine my powershell function to take $args and then pass them in as strings. Wonder why command line arguments can't be passed to functions without wrapping them as strings?
    – ledhed2222
    Commented Apr 4, 2011 at 12:45
  • 1
    Without the quotes it means passing values to arguments $s, $q, and $o. For making this work, you would need to define function xquery($s, $q, $o) {java net.sf.saxon.Query -s:$s -q:$q -o:$o}
    – Gunther
    Commented Apr 4, 2011 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.