There are two ways to supply multiple input files as input to a query:
 
(a) use the doc() function within the query to access the file by URI
 
(b) use an "external variable" (a parameter to the query). You can declare this as
 
declare variable $doc2 as document-node() external;
 
and then supply a value from your calling application using methods on the DynamicQueryContext object.
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Wang, Simon X
Sent: 17 May 2006 02:24
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Help

Hi everybody,

I need your help. When I go to //http://userpages.umbc.edu/~jpak3/ifsm651_lab/samples/java/QueryAPIExamples.java   and down load the source code, I have a question. If we need to get data from two .xml files, like get data from two table in RDBMS, how should we do?

The Key code is like fellows:


import net.sf.saxon.Configuration; 
....



final Configuration config = new Configuration();
final StaticQueryContext sqc = new StaticQueryContext(config);
final XQueryExpression exp = sqc.compileQuery("MyXquery"); 
final DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
dynamicContext.setContextItem(sqc.buildDocument(new StreamSource("MyFirst.xml")));  // If I have a second file MySecond.xml, how should we do?

final Properties props = new Properties();
props.setProperty(OutputKeys.METHOD, "xml");

Simon Wang
Trane Asian Sourcing & Design Center  
Tel: 86-21-5359 9566 ext. 663
Fax: 86-21-6352 9006
E-mail: swang@trane.com