CSE HTML Validator by AI Internet Solutions, the Professional HTML Syntax Checker
CSE HTML Validator logo
Developer Information
CSE HTML Validator is Cleaning Up the Web!

Developer Information

Validating with .NET (not supported by AI Internet Solutions)

This download enables .NET programmers to build CSE HTML Validator validation into their unit tests. It works with version 7 and provides source code, Visual Studio 2005 projects and compiled help which the experienced .NET programmer can use. The download is about 630 KB in size. Not developed or supported by AI Internet Solutions. More about these .NET Web Page Testing Files.

Download .NET Web Page Testing Files

COM DLL wrapper (by third party) is Available (not supported by AI Internet Solutions)

Download COM DLL Wrapper

CSE HTML Validator Lite

Please note that the free version of CSE HTML Validator prior to v6.52 does not support any integration (via any method-- old or new) with other applications. Version 6.52 and above, however, does support integration with third party programs.

Integrating Using the New Method (DLL)

A DLL interface has been developed to interface directly with CSE HTML Validator's validation engine. The old interface method, described below, still works, but now you can use a more direct and powerful approach by interfacing directly with the validator engine through its DLL. This is only available for CSE HTML Validator Std/Pro 4.0 and later and CSE HTML Validator Lite 6.52 and later. This method is highly recommended. For more information, please visit the CSE HTML Validator Developer DLL Information page.

Integrating Using the Old Method

For integrating into HTML editors or other applications, CSE HTML Validator can output an easily parsable validation result file that an application can easily process (note that this is the old method that is still supported; you can now interface directly with HTML Validator's DLL or you can use the old method that is described below).

To get this file cmdlineprocessor.exe (or htmlval.exe for older versions without cmdlineprocessor.exe) is called with command line arguments and the name of an HTML file to validate. HTML Validator validates the HTML file supplied by the command line arguments, and sends the name of the output file to the calling program by sending a message to a window of the calling program. The message contains a handle to a global atom containing the filename of the easily parsable validation results file.

The syntax for calling cmdlineprocessor.exe is

cmdlineprocessor.exe -e,<classname>,<message> <html filename to validate>

Example:

cmdlineprocessor.exe -e,SuperHTMLEditor,43 index.html

This will send the message WM_USER+43 to the window class named 'SuperHTMLEditor' using Windows API calls: PostMessage(FindWindow("SuperHTMLEditor", NULL), (UINT)(WM_USER+atol("43")), 0, (LPARAM)hAtom). The class name cannot contain space characters. Note that 'SuperHTMLEditor' and 43 are arbitrary- use your own name and message. There is no need to know the path to cmdlineprocessor.exe if you use a proper API command (like ShellExecute()) and htmlval.exe instead of cmdlineprocessor.exe because the registry contains the information that Windows needs to locate cmdlineprocessor.exe.

For instance, in Borland C++Builder when you receive a message from Windows, you should receive a TMessage class object. You should then be able to get the filename of the results file with code similar to the following:

ATOM hAtom;
char resultsfilename[256];
hAtom=(ATOM)(Message.LParam);
GlobalGetAtomName(hAtom,resultsfilename,256);
GlobalDeleteAtom(hAtom);

The above copies the results filename to the character buffer resultsfilename and then deletes the global atom. For more information about the atom functions, please reference a Win32 API help file.

The registry entry key HKEY_CURRENT_USER\SOFTWARE\AI Internet Solutions\CSE 3310 HTML Validator can be checked to see if a compatible version of HTML Validator is available. The value name ExternalCapability contains a string value containing an integer. It should currently contain a "2" or higher. It may contain higher numbers. You should check to make sure this value is at least a minimum value to make sure that a compatible version of the Validator is installed. As an additional check, you can also make sure that this key exists: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\htmlval.exe

It is the calling program's responsibility to delete the global atom and to delete the output file of the validator.

A sample output file is (from an older version of the program):

VALIDATOR=CSE HTML Validator
VERSION=2.00 BETA 1
REGISTERED=NO
FILENAME=C:\home\www\www\htmlval\configuration.html
LINESCHECKED=161
LINESIGNORED=0
NUMBEROFTAGNAMES=107
NUMBEROFCLOSINGTAGS=33
PERCENTCLOSED=30.8
NUMBEROFHTMLCOMMENTS=2
NUMBEROFVALIDATORCOMMENTS=0
NUMBEROFERRORS=3
NUMBEROFWARNINGS=0
MESSAGETYPE=ERROR
MESSAGENUMBER=1
LINENUMBER=35
MESSAGE=The attribute value "+1" for the attribute "size" was not enclosed in double quotes when it must be.
MESSAGETYPE=ERROR
MESSAGENUMBER=2
LINENUMBER=100
MESSAGE=A line in the input file exceeds the maximum of 512 characters (including the NULL character).
MESSAGETYPE=ERROR
MESSAGENUMBER=3
LINENUMBER=136
MESSAGE=A line in the input file exceeds the maximum of 512 characters (including the NULL character).
ENDOFFILE=YES

This is only an example file and line length errors (as above) no longer occur with HTML Validator since that limitation has been removed.

Important Notes

  1. Statistical information will always come before the first MESSAGETYPE but the order of the statistical information may change. Lines can also get added and deleted. For example, the number of character entities is given only when the user has "Validate entities" checked.
  2. Every message begins with MESSAGETYPE and ends with another MESSAGETYPE or ENDOFFILE=YES. That is, all the message information for each message is between the beginning MESSAGETYPE line and the next MESSAGETYPE line or between the beginning MESSAGETYPE line and the ENDOFFILE line.
  3. The message information can come in any order and sometimes items may be omitted if it is not available (such as LINENUMBER for comments).
  4. The file will always end with ENDOFFILE=YES.
  5. There are four MESSAGETYPES: ERROR, WARNING, MESSAGE, and COMMENT.
  6. Each message type can have message numbers of 1, 2, 3, etc. (i.e. there can be an error message with a message number 1 as well as a warning message with a message number of 1, but there can't be two error messages with the same message number).

Other Useful Information

  • You may call "cmdlineprocessor.exe -1" to run the validator and open the Program Options Dialog Box/Validator Engine Options. When the user closes the dialog box, the settings will be saved and the validator will exit. You can also call "cmdlineprocessor.exe -2" to do the same for the HTML Configuration Editor. New with v4.0330 and above, "-3" will open the Batch Wizard Options and "-4" will open the Editor Options.

Recommendations

When parsing the output file, we recommend the following for best compatibility:

Do not depend on the order of information. I recommend that you have some sort of data structure that is initialized to values representing undefined information (each message should have its own structure). As you read the file, update the values to indicate that they are defined. This will take care of the fact that comments do not have line numbers so that LINENUMBER will not exist for comments in the output file. Also, some error and warning messages may not have LINENUMBERs and some messages may not have CHARLOCATIONs.

All messages will start with MESSAGETYPE=type. If you do not recognize the MESSAGETYPE, skip down to the next MESSAGETYPE ignoring everything in between. When you get a valid MESSAGETYPE, read the next line and see what it is... if it is LINENUMBER, update that field in your data structure from undefined (perhaps a -1 value) to the actual line number. If you don't understand the next line, just skip it.

New to Version 3.00 and Above

  • CHARLOCATION=x is now also supported for many messages. This value indicates the beginning character location of the text that caused the message to be displayed. Using this, you can take your user directly to the problem by placing the cursor at not only the exact line, but also the character location.
  • CHARLOCATIONLENGTH=x is often (but not always) used with CHARLOCATION to indicate a range of text that caused the message to be displayed. Using CHARLOCATION and CHARLOCATIONLENGTH, an HTML editor can highlight a bad tag name, attribute, attribute value, or other range of text on a line.
  • A single text file containing multiple lines, with each line containing a command line argument, can be passed to HTML Validator (with the -f argument) to avoid having to call the executable for each document to validate. This significantly speeds up validation for multiple documents.

To see what command line arguments CSE HTML Validator and above can accept, see the documentation page about the Command Line Arguments and cmdlineprocessor.exe.

Using -n between lines in the text file can be used to keep your application notified of the status of the processing. For example:

-e,SuperHTMLEditor,43 c:\htmlfiles\document1.html
-n SuperHTMLEditor,1,25
-e,SuperHTMLEditor,43 c:\htmlfiles\document2.html
-n SuperHTMLEditor,1,50
-e,SuperHTMLEditor,43 c:\htmlfiles\document3.html
-n SuperHTMLEditor,1,75
-e,SuperHTMLEditor,43 c:\htmlfiles\document4.html
-n SuperHTMLEditor,1,100

Here, the -n keeps SuperHTMLEditor notified of the percentage complete. Message numbers 43 and 1 are arbitrary.

  • New to version 3.04, you may add a numeric optional extra parameter to -e. Example: "-e,SuperHTMLEditor,43,x", where x is the extra parameter
    • Add 1 to x to specify that the output should be in the user readable format. The default is the easily parsable format.
    • Add 2 to specify silent mode so no dialog boxes are displayed, even if an error occurs. The default is not to be in silent mode.
  • Also new to version 3.04, you may specify another message number to send in case of an error. You must include the above optional parameter if you want to specify a message number to send in case of an error. Example: "-e,SuperHTMLEditor,43,0,x", where x specifies the message to send in case of an error. WM_USER is added to x. The error code is sent as the lParam argument for the message. A list of error codes follows:
    • 98110601 - window name or message was not supplied with command line arguments
    • 98110602 - document filename was not supplied with command line arguments
    • 98110603 - GlobalAddAtom() failed
    • 98110604 - FindWindow() failed
    • 98110701 - PostMessage() failed
    • 98110702 - no active categories in HTML Configuration File
    • 98110703 - count not open the HTML document for validation
    • 98110704 - HTML document has same filename as output file
    • 98110705 - error opening output file
    • 98110706 - error validating file (no specific information available)
  • Also new to version 3.04, you may add a numeric optional extra parameter to -f. Example: "-f,x", where x is the extra parameter
    • Add 1 to x to always continue processing following lines after an error has occurred processing the current line. The default is to ask the user to continue or not if not in silent mode. If in silent mode, the default is to not continue.
    • Add 2 to x to specify silent mode so that no dialog boxes are displayed. This only applies to dialog boxes that are displayed only for the -f argument. Does not affect other dialog boxes. For more silent operation, also specify the silent flag in any -e commands.

Copyright © 1997-2008 AI Internet Solutions. Sun, May 04 2008 Privacy Policy