I’ve started to implement your second suggestion but I’m having problems with the collection URI resolver. The resolve() method must return an iterator to the sequence of files, a SequenceIterator, but I’m completely confused on which type this sequence is and therefore how to create a SequenceIterator from it. I assumed a collection of strings or object that represents a file URI would suffice but I can’t see which data type these should all be, can you advise?




From: Michael Kay []
Sent: 20 June 2013 14:13
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Java API: transforms with multiple XML input files


There are two ways you could do this.


One is to pass a sequence of document nodes as a parameter to the transformation. Given a file, you can construct an XdmNode using a s9api DocumentBuilder, and then you can construct a sequence containing these nodes using the XdmValue constructor. You then pass this as a parameter using transformer.setParameter(). You declare the parameter at the top level of the stylesheet using xsl:param. You can either supply a dummy "main input document" to the stylesheet, or start the execution at a named template.


Another way is to use a collection - typically the default (unnamed) collection. Define a class that implements CollectionURIResolver, and that returns the required documents when it is called; register it using processor.setConfigurationProperty(FeatureKeys.COLLECTION_URI_RESOLVER), and then get the collection using something like


<xsl:for-each select="collection()">


Michael Kay




On 20 Jun 2013, at 13:40, Urquhart, Callum wrote:



I am investigating software and libraries we can use to perform a series of transformations. The plan is to use MapForce to produce XSLTs and use the Java API of Saxon-EE to perform the actual transformations.


We need the ability to input several XML files into the same XSLT (i.e. merge/combine functionality) and produce the appropriate output (one or several files). I have some basic code (below) which uses the Saxon Java API to transform a single XML to single output file, but I can’t immediately see how to handle multiple input files into the same XSLT with the Java API. Is it possible, and if so , how do I do so?


I have seen examples via Google that use the command line to feed several XML files into an XSLT, but it’s not clear if this is feeding each XML file into the XSLT separately, or feeding all XML files into the XSLT in one operation.


Any help or comments would be useful,




Test code:


StreamSource inputXsdSource = new StreamSource(new File("mf-ExpReport.xsd"));

              StreamSource inputXmlSource = new StreamSource(new File("mf-ExpReport.xml"));

              StreamSource xsltSource = new StreamSource(new File("MappingMapToExpReport-Target.xslt"));

              Serializer target = new Serializer(new File ("output.xml"));


              Processor proc = new net.sf.saxon.s9api.Processor(true);




                     SchemaManager schemaManager = proc.getSchemaManager();


                     System.out.println("Loading input XSD");




                     System.out.println("Validating input XML");




                     XsltCompiler compiler = proc.newXsltCompiler();


                     System.out.println("Compiling XSLT");

                     XsltExecutable xsltExec = compiler.compile(xsltSource);



                     System.out.println("Loading XSLT");

                     XsltTransformer transformer = xsltExec.load();










              catch (Exception ex)




This email is sponsored by Windows:

Build for Windows Store.
saxon-help mailing list archived at