All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.lutris.xml.xmlc.validate.Validate

java.lang.Object
   |
   +----com.lutris.xml.xmlc.validate.Validate

public class Validate
extends Object
This class validates HTML for use in a project with XMLC. In one mode it examines compiled HTML objects and creates a script. In the other mode it reads the script and ensures that the right tags exist. This is usefull after the HTML has been edited: if you are about to hand off the HTML to a designer, you can run the validator to generate a script, then when you get the HTML back you can check the HTML against the script to verify that the designer did not accidentally delete any tags.

Usage:

      Validate gen class [class class class....]
      Validate scriptname
  

The script is read one line at a time. Each line is a command, directing the validator to take some action. The syntax of the commands is as follows:

      page classname 
      id tag-type|*  
      class class n|tag-type|*
      in id id|*
      in class class|*
      only ids id id id...
      only classes class class class...
      # comment
  

The command "page" switches to a new page. Use a full classname. The page must have already been compiled with XLMC (in the future the ability to read files will be supported).

The command "id" requres that there be a tag with the given id and type. If the type is "*" then any type is allowed.

The command "class" takes a class name and either an integer or a tag type. If an integer N is specified, then it requires that there be N tags with the given class name. If N is "*", then there must be one or more. If a tag type is specified, then there must me exactly one tag with the given class, and it's type must match (e.g. "span").

The command "in id" restricts the search scope of the "id" and "class" commands to the tag with the given id. The current search scope is used to find the tag with the given id, so the search scope is always reduced to a subset of the current scope, unless id is "*". If id is "*" then the search scope is reset to the whole document.

The command "in class" restricts the search scope of the "id" and "class" commands to the first tag found with the given class. The current search scope is used to find the tag with the given class, so the search scope is always reduced to a subset of the current scope, unless class is "*". If class is "*" then the search scope is reset to the whole document.

The command "only ids" requires that at the current scope there must exist only the specified id names. If any other ids exist it will cause an error and their id names will be listed.

The command "only classes" requires that at the current scope there must exist only the specified class names. If any other classes exist it will cause an error and their class names will be listed.

The recommended usage for the validator is to add the following lines to your makefile in the directory where your compiled HTML resides (where the makefile that lists all the html classes is):

  generate:
          &[ ! -f validate.script ] || echo "validate.script exists."
          & ! -f validate.script ] 
          &CLASSPATH=$(CLASSPATH) ; PATH=$(PATH) ; export CLASSPATH PATH  ; \
          set -x ; \
          ($(JAVA) com.lutris.xml.xmlc.validate.Validate gen $(HTML_CLASSES:%=$(PACKAGE).%) > validate.script; [ -f validate.extra ] && cat validate.extra >> validate.script; true) || exit 1
  
validate: & -f validate.script ] || echo "no file validate.script"; & -f validate.script ] &CLASSPATH=$(CLASSPATH) ; PATH=$(PATH) ; export CLASSPATH PATH ; \ set -x ; \ $(JAVA) com.lutris.xml.xmlc.validate.Validate validate.script
This will add two rules to your makefile. When your HTML is at an appropriate state, for example right before you hand it out to someone else to edit, type "make generate" (remove the file validate.script, if it exists, first). This will generate a file validate.script which will be used later to validate all the compiled HTML in the current directory.

When you wish to validate the HTML, for example after you get it back from someone else, you must first put it in the tree and compile it (do a normal "make"). After it all compiles, then type "make validate" and the validator will process the script validate.script and check the HTML.

The tags in your HTML will probably have additional contstraints that the validator program does not know about. In this situation you use the validate.extra file. It is appened onto the end of the resulting validate.script file whenever it is generated. You can add your own additional checks here and they will not be overwritten when you generate a new validate.script file. The validate.script file may be edited also, but then you must be carefull to save it under a new name.


Method Index

 o main(String[])
There are two modes: if you pass in one arg it is assumed to be the filename of the script to read.

Methods

 o main
 public static void main(String args[]) throws Exception
There are two modes: if you pass in one arg it is assumed to be the filename of the script to read. Otherwise a script is generated and written to stdout. The first argument is assumed to be "gen" and is skipped. The rest of the arguments are the class names of the pages to examine.

Parameters:
args - the initial arguments.
Throws: Exception
If an error occurs.

All Packages  Class Hierarchy  This Package  Previous  Next  Index