XHTML Validation using Apache Ant

Hi All,

I have been trying to validate XHTML pages offline, using Apache Ant.  
Ant has an <xmlvalidate> task which seems to work well, except for being 
very very slow.  If you make a local cache of DTDs (i.e. and XML 
catalog), <xmlvalidate> runs perhaps ten times faster than if you don't 
(in which case it fetches the DTD again for every file you validate. I'm 
trying to validate about 2000 files).

There doesn't seem to be an easy way to maintain a local cache of DTDs.  
This isn't a serious problem ... except for XHTML 1.1, in which the 
modularisation means the DTD is split into dozens of fragment files.  
Making a local copy of these is a laborious error-prone manual task 
because the W3 website prohibits directory access to 
http://www.w3.org/TR/xhtml11/DTD/ (and thus prevents using a tool such 
as Wget to make a local cache).

Has anyone else had experience with this that might help me?

Ideally, the W3 webmaster would enable directory browsing so that Wget 
could be used to make local copies.  Would that be possible?

Rick :-)



PS Here's my Ant buildfile for the curious:

<?xml version="1.0"?>
<!-- $Id: build.xml,v 1.56 2004/02/11 08:04:41 rick Exp $ -->

<project name="Website Validation" default="validate" basedir=".">

  <xmlcatalog id="commonDTDs">
    <dtd
         publicId="-//WHR//DTD JINDEX 1.0//EN"
         location="htdocs/dtd/jindex.dtd"/>
    <dtd
         publicId="-//WHR//DTD PAGE 1.0//EN"
         location="htdocs/dtd/page.dtd"/>
    <dtd
         publicId="-//WHR//DTD JPAGE 1.0//EN"
         location="htdocs/dtd/jpage.dtd"/>
    <dtd
         publicId="-//W3C//DTD XHTML 1.0 Strict//EN"
         location="htdocs/dtd/w3c/xhtml1-strict.dtd"/>
    <dtd
         publicId="-//W3C//DTD XHTML 1.0 Transitional//EN"
         location="htdocs/dtd/w3c/xhtml1-transitional.dtd"/>
    <dtd
         publicId="-//W3C//DTD XHTML Basic 1.0//EN"
         location="htdocs/dtd/w3c/xhtml-basic10.dtd"/>
    <dtd
         publicId="-//W3C//DTD XHTML 1.1//EN"
         location="htdocs/dtd/w3c/xhtml11.dtd"/>
  </xmlcatalog>

  <!-- 
=================================================================== -->

  <target name="validate"
          depends="xml.validate, xhtml.validate"
          description="=== Validates all XML and XHTML files against 
their DTD ===">

  </target>

  <!-- 
=================================================================== -->

  <target name="xml.validate"
          description="=== Validates all XML files against their DTD ===">

      <xmlvalidate>
        <xmlcatalog refid="commonDTDs"/>
        <fileset dir="xdocs" includes="**/*.xml"/>
      </xmlvalidate>

  </target>

  <!-- 
=================================================================== -->

  <target name="xhtml.validate"
          description="=== Validates all XHTML files against their DTD ===">

      <xmlvalidate>
        <xmlcatalog refid="commonDTDs"/>
        <fileset dir="htdocs" includes="**/*.html"/>
      </xmlvalidate>

  </target>

</project>




-- 
Registered Office: Roke Manor Research Ltd, Siemens House, Oldbury, Bracknell,
Berkshire. RG12 8FZ

The information contained in this e-mail and any attachments is confidential to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.

Received on Wednesday, 11 February 2004 05:43:08 UTC