W3C home > Mailing lists > Public > www-validator@w3.org > January 2004

Re: validating (x)html documents from the command line

From: Beton, Richard <richard.beton@roke.co.uk>
Date: Fri, 30 Jan 2004 16:13:02 +0000
To: Olav <olav@bogus.net>
Cc: www-validator@w3.org
Message-ID: <401A828E.2060105@roke.co.uk>

Olav wrote:

>is there any way to validate a html document from the unix or dos
>command line?
>
>(the objective is to check a lot of files in a flash without having to
>click buttons and selecting from file dialogs for each file)
>  
>


I converted my site to XHTML and now I use Ant with the validate task to 
check all my files before I upload them.
(http://ant.apache.org).

Here's the relevant bits of my Ant buildfile:


<?xml version="1.0"?>
<project name="WHR Website" default="validate" basedir=".">

  <xmlcatalog id="commonDTDs">
    <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"/>
    <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"/>
  </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>


Note that I have a local cache of DTDs to speed it up (in my htdocs/dtd 
folder).  I have three additional DTDs that I use to validate XML files 
of my own format - you can ignore these unless you also have XML source 
files, in which case you substitute your own.

I have a question too.  The Ant validate task is quite slow - monitoring 
tools suggest it does a lot of network i/o (presumably fetching DTDs 
etc).  Does anyone know of a way to speed this up, in addition to using 
a local XML catalogue.

Rick :-)


-- 
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 Friday, 30 January 2004 11:16:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 25 April 2012 12:14:10 GMT