Forgive me for saying this, but the CLI is already like a small programming language. Such type of extension won’t make much (if any) difference to that.


Ant is too… JAVA… for my taste and XProc… god I can’t wait for it to become more stable (at least CR) and thus implemented not only in JAVA. I want it, really. I’m just waiting.


As for the whole idea of XPath expression parameters, I’ve said this before – I don’t see much sense for node selection (as the previous examples I gave) either, but I see a use case when using XPath for direct string manipulation. Functions like codepoints-to-string(), concat() and all other functions available in XPath 2.0 that I can’t think of right now. True, stylesheets/queries can be adjusted to do fine without it, but we don’t always have (direct) control over the stylesheet.


And if you really need it outside the stylesheet/query, you can do that from any language binding, since you could perform the operation within that language. This applies when you’re not using the CLI. In CLI however, passing an XPath expression when you invoke the processor may be your last chance to do this type of manipulation.


From: [] On Behalf Of Michael Kay
Sent: Friday, July 27, 2007 2:32 AM
To: 'Mailing list for SAXON XSLT queries'
Subject: Re: [saxon] how to set a global variable on the command line


I've no intention of turning the command line interpreter into a miniature programming language. If you want a scripting language for transformations, use Ant or XProc.


There never has been a syntax for XPath that allows you to bind namespace prefixes within the expression. There should be, and I've raised the possibility on the xsl-list of defining an informal standard in this area. But it turns out to be surprisingly difficult, given the variety of situations where it has to work.


Even if that obstacle were overcome, I'm far from convinced that supplying parameter values by means of an XPath expression is something that really makes sense.


Michael Kay


From: [] On Behalf Of Vasil Rangelov
Sent: 27 July 2007 00:16
To: 'Mailing list for SAXON XSLT queries'
Subject: Re: [saxon] how to set a global variable on the command line

How about –rns option or something like that which would accept a prefix=URI pair as the next argument. Later, this prefix could be used in XPath expressions within the command line. A param=value pair that accepts XPath expressions should probably be marked accordingly with something (say “~”). The character of choice would be of no importance.



Transform  -rns h=  -in test.xml test.xsl   ~exampleParameter=//h:code


In the worse case, you could use a special prefix (say “!”) for option that is actually a prefix=URI pair. Something like:

Transform  !h=  -in test.xml test.xsl   ~exampleParameter=//h:code


And/Or in the worst case, just allow {} to be used as namespace resolvers within the expression. Makes for quite a verbose expression, but it would work in edge cases:

Transform  -in test.xml test.xsl   ~exampleParameter=//{}code

Wasn’t that one actually path of XPath 1.0’s syntax or am I on the wrong track?


From: [] On Behalf Of Michael Kay
Sent: Thursday, July 26, 2007 11:05 AM
To: 'Mailing list for SAXON XSLT queries'
Subject: Re: [saxon] how to set a global variable on the command line


It is possible to pass in a document node using the syntax




It isn't possible to pass in an element node. You will have to declare the external variable to expect a document node, and then do the selection of the element node within the query.


Another alternative of course is to pass the filename in as a string, and fetch the document from within the query.


I know that there are XSLT and XQuery products that allow parameter values to be set using an XPath expression, but Saxon doesn't. I've never worked out a sensible way that would allow the namespace context to be set for evaluating such expressions, and without that the facility seems fairly useless.


Michael Kay


From: [] On Behalf Of
Sent: 26 July 2007 00:31
Subject: [saxon] how to set a global variable on the command line

I have an XQuery that I want to run on the command-line.  It is in the form of a function call with the argument set to a global variable:


declare function myfunc($in as element(inType)) as element(outType)  {….}

declare variable $in as element(inType) external;



In order to run this XQuery, the variable $in has to be set.  It should be set to the root node in the input XML file, but I haven’t been able to figure out the right syntax to do this.


I am able to set global variables to untyped values, like:


java –cp saxon.jar net.sf.saxon.Query transform.xq param=value


But how do I pass in a document node for “param”?  I have tried using {doc(‘in.xml’}/in} (where in.xml is the input file, and in is the root node), but this expression gets passed in as a string.


What’s the right way to do this?  Is it even possible on the command-line?





This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.