Subject: Re: [xsl] Use XSLT to check a bunch of XHTML files for well-formedness? From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 16 Feb 2021 21:03:38 -0000 |
Hi Folks,the XSLT:
I have a folder containing a large number of XHTML files.
I want to know: for each file, is it well-formed?
What is the easiest and fastest way to see if each file is well-formed?
My thinking has been to create a super-simple XSLT program:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
<xsl:template match="*" />
</xsl:stylesheet>
and then run the XSLT on each XHTML file.
I have a command file (.bat file) that loops over each XHTML file and runs
-o:well-formedness\%%i
for %%i in (xhtml\*.xhtml) do ( echo %%i java -jar saxon-ee-10.1.jar %%i -xsl:test-well-formedness.xsl
)Transform command to process an entire directory of source files."
That works, but it's pretty slow.
So, I looked into compiling my XSLT program:
On this SAXON web page it talks about Compiling a Stylesheet:
https://www.saxonica.com/html/documentation/using-xsl/compiling.html
On the page it says:
In simple cases, you can exploit the ability to process an entire directory of source files using a single invocation of the Transform command on the command line.
That sounds perfect.
But the web page, as far as I can tell, doesn't describe how to "use the
Start with a named template and pull in the files or URIs with the Saxon specific argument to the "collection" or "uri-collection" function:
<xsl:template name="xsl:initial-template"> <xsl:value-of select="uri-collection('?select=*.xhtml') ! . || ' : ' || doc-available(.)" separator=" "/> </xsl:template>
In theory I think that should check with doc-available if the file is well-formed or not. Haven't tested however.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: Use XSLT to check a bunch, Chris Papademetrious | Thread | Re: [xsl] Use XSLT to check a bunch, Martin Honnen martin |
[xsl] Re: Use XSLT to check a bunch, Chris Papademetrious | Date | Re: [xsl] Use XSLT to check a bunch, Martin Honnen martin |
Month |