Reputation: 443
I am new to XML/XSLT
. I would be pleased if anyone could give me some hints or an explanation about my question.
I have some XML <SquishReport>
files in XML
and want to check them if there are errors in them, otherwise I'm not interested in the content of. To be shortened: check if there is any error in the report files. I have written a script with XSLT
format that checks whole the file and gives a report regarding only one file and colors the parts.
Now I want to check all XML
files existing in the some folders. Here is the description:
XML
files differs in each folder. Then I have to find the number of XML
files in each folder before considering all XML
files.if
condition for test/message
part if XML file.Your ideas and helps are highly appreciated!
Upvotes: 0
Views: 39
Reputation: 57149
I have written a script
I think you mean: Sean B. Durkin has written, or at least in part, because you link to an answer containing code written by him.
You tagged your question with XSLT 1.0 and XSLT 2.0, so I am going to assume that you can use XSLT 2.0.
the number of XML files differs in each folder. Then I have to find the number of XML files in each folder before considering all XML files.
This doesn't matter. Use the collection
function and let it go over your folder, most processors support going over them recursively.
The code that is linked above reads all messages. But I am looking for finding only errors in the files and gathering all error description for each folder. I am thinking of a if condition for test/message part if XML file.
"if XML file" seems to suggest that you want this condition to apply only when it is an XML file and that your folders contain other files as well. Use doc-available
for that, a function that only succeeds if the file is actually XML.
In XSLT 3.0 you can use xsl:try
, which would ignore any errors raised when trying to load a document that is not XML.
Also, some processors allow you to use the collection
function and ignore any files that are not parsable as XML. Check the documentation of your processor for how to do this.
at the end prints out how many files have error out from the whole file in one folder separatly. e.g. three from six with the detailed description in which part there is error.
This is a standard XSLT task. Use sum
and in your matching templates you can differentiate based on base-uri
, if you want to distinguish between folders. You can even sort the results that way if you want.
Upvotes: 1