tags:

views:

25

answers:

1

I want to use saxon for xpath queries but i don't know to load multiple xml files.

I'm trying to use saxon with command line from windows

I read in saxon manual that i can use the command:

Query.exe -s:myDataFile.xml -q:myQueryFile -o:myOutputFile

but i don't know how to load multiple xml files and not just one

edit: I have many xml files myDataFile1.xml, myDataFile2.xml, myDataFile3.xml ... and i want to run the query to alla these files So i want to load all all files and then query them (I don't want to query every single file and then concatenate the results)

+1  A: 

Use the standard XPath 2.0 function collection().

The documentation for the Saxon-specific implementation of collection() is here.

You can use the standard XPath 2.x collection() function, as implemented in Saxon 9.x

The Saxon implementation allows a search pattern to be used in the string-Uri argument of the function, thus you may be able to specify after the path of the directory a pattern for any filename starting with report_ then having two other characters, then ending with .xml.

Example:

This XPath expression:

collection('file:///c:/?select=report_*.xml')

selects the document nodes of every XML document that resides in c:\ in a file with name starting with report_ then having a 0 or more characters, then ending with .xml.

Dimitre Novatchev