Page 1 of 1

generate report from multiple "find" results

Posted: Wed May 13, 2015 9:57 pm
by DJH
I would like to run multiple "find" operations and create a single output from them. For example, I would like to:
- report the DOCTYPE
- report on specific attribute value found
- report on specific element found
- report on specific attribute found
- report on specific text string found in element
Normally, I write XSLT and can use the result-document output to write out results based on an XPath selector, but in this case, I want to run a process on hundreds of files and capture the document name and the results of the different "find" operations for each file. So I am wondering if XQuery would be a better way to go, but I don't have XQuery experience.

Also, I need to be able to run this process while ignoring the reference in the DOCTYPE to a DTD which may not be available.

Does anyone have some advice?

This may be a precursor for writing some Schematron, but first I want to know what the files contain and creating the report will give me some data to discuss with the person providing the files.

Re: generate report from multiple "find" results

Posted: Thu May 14, 2015 12:04 pm
by Radu
Hi,

Please see some answers below:
Normally, I write XSLT and can use the result-document output to write out results based on an XPath selector, but in this case, I want to run a process on hundreds of files and capture the document name and the results of the different "find" operations for each file.


Actually you can use the XSLT 2.0 collection function to iterate from an XSLT stylesheet an entire set of files located in a certain folder:

Code: Select all

<xsl:variable name="files" select="collection('../foo/?select=*.xml')"/>
and them load them using the document function.
You can apply the XSLT on the first document in the folder because it will actually work on all documents from the folder.
So I am wondering if XQuery would be a better way to go, but I don't have XQuery experience.
The collection function should also be available in XQuery.
Also, I need to be able to run this process while ignoring the reference in the DOCTYPE to a DTD which may not be available.
This is not possible, at least with XSLT, XQuery or any XML-aware process. But you can create an XML catalog which maps the DTD location to an empty file. But if the XML documents contain entities defined in the DTD, the processing will break.

Regards,
Radu