how to load multiple xml files with saxon

邮差的信 提交于 2019-12-04 06:24:09

问题


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:


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.



来源:https://stackoverflow.com/questions/3882717/how-to-load-multiple-xml-files-with-saxon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!