Package dk.brics.dsd.ant

DSD validate task.

See:
          Description

Class Summary
DSDTask This provides a Jakarta Ant task for validating DSD files.
 

Package dk.brics.dsd.ant Description

DSD validate task.

Description

Performs a validation of a single XML document against a Document Structure Description (DSD2). Documents can be validated against an internally defined DSD using a processing instruction

   <?xml version="1.0" encoding="ISO-8859-1"?>
   <?dsd href="url of DSD"?>

   <dsd:dsd>
   ...
   </dsd:dsd>

The class is wrapped within the DSD validator, so assuming that the validator, dsd.jar, is in your current classpath, define the task in your build file as

  <taskdef name="dsdvalidate" classname="dk.brics.dsd.ant.DSDTask"/>

Parameters

Attribute Description Required
file The file to validate, specified as either the simple filename (if the file exists in the current base directory), a relative-path filename, or a full-path filename.
Yes
dsd The name os the DSD to validate against. It overrides the one embedded within the file. No
dest The destination file that the result is written to. The result is the document with the defaults resolved and any errors noted. Note that this file will have all the imported (included) files expanded within in it. No
verbose Prints out verbose messages about progress. Default is false. No
stats Prints out the time taken for the validation. No
failonerror Aborts build if set to true. Default is true. No

Examples

  <taskdef name="dsdvalidate" classname="dk.brics.dsd.ant.DSDTask"/>

  <target name="testTask">
     <dsdvalidate file="/Library/DSDs/uri.dsd" />
  </target>

validates /Library/DSDs/uri.dsd, producing the output

   [dsdvalidate] Validating: /Library/DSDs/uri.dsd
   [dsdvalidate] Document is valid!

for a valid document, or

   [dsdvalidate] Validating: /Library/DSDs/uri.dsd
   [dsdvalidate] Document is invalid!
   [dsdvalidate] Error: contents of element 'dsd:optional' does not match declaration
   [dsdvalidate] Error: sub-element 'dsd:sequenc' of element 'dsd:optional' not declared
   [dsdvalidate] Error: sub-element 'dsd:stringtype' of element 'dsd:sequenc' not declared
   [dsdvalidate] Error: sub-element 'dsd:char' of element 'dsd:sequenc' not declared
   [dsdvalidate] 4 errors detected. See output document for details.
   <target name="testTask">
      <dsdvalidate file="/Library/DSDs/uri.dsd" verbose="true"/>
   </target>

validates /Library/DSDs/uri.dsd, producing the output

   [dsdvalidate] Validating: /Library/DSDs/uri.dsd
   [dsdvalidate] Loading instance document /Library/DSDs/uri.dsd...
   [dsdvalidate] Loading schema document /Library/DSDs/dsd2.dsd...
   [dsdvalidate] Parsing schema...
   [dsdvalidate] Validating...
   [dsdvalidate] Document is valid!

for a valid document, or

   [dsdvalidate] Validating: /Library/DSDs/uri.dsd
   [dsdvalidate] Loading instance document /Library/DSDs/uri.dsd...
   [dsdvalidate] Loading schema document /Library/DSDs/dsd2.dsd...
   [dsdvalidate] Parsing schema...
   [dsdvalidate] Validating...
   [dsdvalidate] Document is invalid!
   [dsdvalidate] Error: contents of element 'dsd:optional' does not match declaration
   [dsdvalidate] Error: sub-element 'dsd:sequenc' of element 'dsd:optional' not declared
   [dsdvalidate] Error: sub-element 'dsd:stringtype' of element 'dsd:sequenc' not declared
   [dsdvalidate] Error: sub-element 'dsd:char' of element 'dsd:sequenc' not declared
   [dsdvalidate] 4 errors detected. See output document for details.
   <target name="testTask">
      <dsdvalidate file="/Library/DSDs/uri.dsd" verbose="true" stats="true" dest="uri-val.dsd"/>
   </target>

validates /Library/DSDs/uri.dsd, producing the output

   [dsdvalidate] Validating: /Library/DSDs/uri.dsd
   [dsdvalidate]  to external file: uri-val.dsd
   [dsdvalidate] Loading instance document /Library/DSDs/uri.dsd...
   [dsdvalidate] Loading schema document /Library/DSDs/dsd2.dsd...
   [dsdvalidate] Parsing schema...
   [dsdvalidate] Validating...
   [dsdvalidate] Document is valid!
   [dsdvalidate] [loading+parsing time: 6679ms, validating time: 21917ms]

for a valid document.



Copyright © 2002 Anders Møller.