There's no direct way to set the default collection from the command line.
You can nominate a CollectionURIResolver written in Java, and the CollectionURIResolver can nominate the default collection, but that's probably a bit long-winded.
A better solution, as Andrew suggested, is probably to set an ordinary query parameter (external variable) from the command line, and use this as an argument to the collection() function.
Michael Kay

From: [] On Behalf Of
Sent: 15 September 2008 17:35
Subject: [saxon] Setting the default collection at the command line

How do I set the default collection at the command line for XQuery with Saxon 9-0-0-7?

I have a directory at file:///foo/bar that contains XML documents.

I also have a query:
element $lunch{for $l in collection('file:///foo/bar?recurse=yes;select=*.xml;on-error=ignore')//element(*, Meal)
return $lunch}

What I want to do is pass the directory /foo/bar in at the command line so I can change my query to:
element $lunch{for $l in collection()//element(*, Meal)
return $lunch}

This is because the query is used on many different directories at different times. I want to reuse the query without editing it.

- Matthew

This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of JPMorgan Chase & Co., its subsidiaries and affiliates. This transmission may contain information that is privileged, confidential, legally privileged, and/or exempt from disclosure under applicable law. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or use of the information contained herein (including any reliance thereon) is STRICTLY PROHIBITED. Although this transmission and any attachments are believed to be free of any virus or other defect that might affect any computer system into which it is received and opened, it is the responsibility of the recipient to ensure that it is virus free and no responsibility is accepted by JPMorgan Chase & Co., its subsidiaries and affiliates, as applicable, for any loss or damage arising in any way from its use. If you received this transmission in error, please immediately contact the sender and destroy the material in its entirety, whether in electronic or hard copy format. Thank you. Please refer to for disclosures relating to UK legal entities.