xsl-list
[Top] [All Lists]

Re: [xsl] Use XSLT to check a bunch of XHTML files for well-formedness?

2021-02-16 15:18:13
In addition to all the other suggestions, something I've done is I've used unparsed-text-available() to know whether or not the file is there, followed by doc-available() to know whether or not the file is well-formed.

Just using doc-available() will fail if the file is not there or if it is not well-formed, but I don't know which.

. . . . . . Ken

At 2021-02-16 20:54 +0000, Roger L Costello costello(_at_)mitre(_dot_)org wrote:
Hi Folks,

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 the XSLT:

for %%i in (xhtml\*.xhtml) do (
echo %%i
java -jar saxon-ee-10.1.jar %%i -xsl:test-well-formedness.xsl -o:well-formedness\%%i
)

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 Transform command to process an entire directory of source files."

What do you recommend?

/Roger







--
Contact info, blog, articles, etc. http://www.CraneSoftwrights.com/s/ |
Check our site for free XML, XSLT, XSL-FO and UBL developer resources |
Streaming hands-on XSLT/XPath 2 training class @US$125 (5 hours free) |
Essays (UBL, XML, etc.) http://www.linkedin.com/today/author/gkholman |
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>