Quick jump to function:
General Information
| • | Function and procedure names are case insensitive. |
| • | Integer expressions are computed from left to right, without regard to operator precedence. |
| • | Comments can be included in the program by beginning them with "/*" and ending them with "*/". For example: /* This is a comment */ |
Variable/Symbol Names
| • | must begin with an alphabetic character |
| • | setting variables in integer and string expressions is possible |
| • | To access a variable, use $name. The return value is a string if name is accessed in a string expression, or an integer if name is accessed in an integer expression. #name can also be used in an integer expression. |
| • | To increment an integer variable by one in an expression, use $name++, to decrement by one, use $name--. To increment an integer variable by one using a statement, use $name++;, to decrement by one, use $name--;. Note that using # instead of $ is also valid. |
$name=string exp value;
Creates a variable called $name (if it doesn't already exist), and sets its value to value. The return value is value and is a string.
#name=int exp value;
Creates a variable called $name (if it doesn't already exist), and sets its value to value. The return value is value and is an integer.
Data Types
| • | int - an integer such as -7, 0, 89, etc. |
| • | int exp - an expression that evaluates to an integer such as -7, 0, 89, 5+3, 56-34, 3*2, 6*(7-3), etc.; variable names and functions returning an int can be used |
| • | !int1 : returns 1 if int1 is 0, else returns 0 |
| • | int1+int2 : returns the sum of int1 and int2 (int1+int2) |
| • | int1-int2 : returns int1-int2 |
| • | int1*int2 : returns int1*int2 |
| • | int1/int2 : returns int1/int2; generates an error if int2 is 0 |
| • | int1&int2 : returns the bitwise AND of int1 and int2 |
| • | int1|int2 : returns the bitwise OR of int1 and int2 |
| • | int1==int2 : returns 1 if int1 and int2 are equal, else returns 0; note the double equal signs |
| • | int1&&int2 : returns 1 if int1 and int2 are both nonzero, else returns 0 |
| • | int1||int2 : returns 1 if either or both int1 and int2 are nonzero, else returns 0 |
| • | int1>=int2 : returns 1 if int1 is greater than or equal to int2, else returns 0 |
| • | int1<=int2 : returns 1 if int1 is less than or equal to int2, else returns 0 |
| • | int1>int2 : returns 1 if int1 is greater than int2, else returns 0 |
| • | int1<int2 : returns 1 if int1 is less than int2, else returns 0 |
| • | int1<>int2 : returns 1 if int1 does not equal int2, else returns 0 |
| • | int1!=int2 : returns 1 if int1 does not equal int2, else returns 0 |
| • | float exp - similar to an int expression but with floating point numbers instead of integers; should not be of much use for tag name programs |
| • | string exp : an expression that evaluates to a string |
| • | constant strings can be enclosed in double quotes (") or single quotes ('), such as "This is a string" or 'This is also a string' |
| • | string1+string2 : concatenates string1 and string2, returns string1string2 |
Flow Control
do { statement; ... } while (int exp);
Executes a statement or statement block while the integer expression is true (nonzero). The statement or statement block is executed at least once.
if (int exp) { statement; ... } [else { statement; ... }]
Executes a statement or statement block, depending on the value of the integer expression. Executes the statement or statement block immediately following if if the integer expression is nonzero, else executes the statement or statement block following else if the integer expression is 0. The else part is optional.
for (statement1; int exp; statement2) { statement3; ... }
Executes statement1 if it exists, then evaluates the required integer expression. If the integer expression is nonzero, then statement3 is executed, otherwise control returns to the statement immediately following the block that contains statement3. If the statement3 block is executed, statement2 is executed immediately afterwards if it exists. The integer expression is then reevaluated and the loop continues until the integer expression evaluates to zero. statement1 and statement2 are both optional and may be single statements or statement blocks. statement3 may be a single statement or a statement block.
For example, this loop continues while the integer expression is nonzero: execute statement1, evaluate integer expression, execute statement3 block, execute statement2, evaluate integer expression, execute statement3 block, execute statement2, evaluate integer expression, ...
while (int exp) { statement; ... }
Continues executing a statement or statement block while the integer expression is true (nonzero).
Functions
To define your own function, add a function to the functions program type in the following format (note that the keyword function must begin at the first character of a line):
function functionname() { statement; ... }
To call a function, use @functionname();.
Special Functions
| • | onConfigLoad() - this function is called when a configuration is loaded; it can be used to specify the validation modes that the configuration supports |
| • | onUnknownCSSPropertyMessage() - this function is called when a CSS property is unknown and a validator error message is about to be generated; this function can be used to ignore unknown CSS properties and/or to change or display additional messages when certain unknown CSS properties are used; the following variables are defined when this function is called and may be modified before the validator message is displayed: (New v7.9910) |
| • | $oucpm_property - the name of the unknown CSS property |
| • | $oucpm_msgtext - the default message text of the validator message that will be displayed |
| • | $oucpm_msgcat - the default message category of the validator message that will be displayed |
| • | $oucpm_msgflags - the default message category of the validator message that will be displayed; set to 0 to cancel the message |
| • | $oucpm_msgid - the default message ID of the validator message that will be displayed; the default is -1 for no message ID |
| • | $oucpm_msgtype - the default message category of the validator message that will be displayed; the default is $MSG_ERROR |
| • | onUnknownElementMessage() - this function is called when an HTML/XHTML element is unknown and a validator error message is about to be generated; this function can be used to ignore unknown elements and/or to change or display additional messages when certain unknown elements are used; the following variables are defined when this function is called and may be modified before the validator message is displayed: (New v7.9910) |
| • | $ouem_element - the name of the unknown element |
| • | $ouem_msgtext - the default message text of the validator message that will be displayed |
| • | $ouem_msgtextappend - an additional message that is appended to the end of $ouem_msgtext; the default is " Did you misspell it?" |
| • | $ouem_msgtextprepend - an additional message that is appended to the front of $ouem_msgtext; the default is an empty string (New v8.0100) |
| • | $ouem_msgcat - the default message category of the validator message that will be displayed; the default is "" for no category |
| • | $ouem_msgflags - the default message category of the validator message that will be displayed; set to 0 to cancel the message |
| • | $ouem_msgid - the default message ID of the validator message that will be displayed; the default is -1 for no message ID |
| • | $ouem_msgtype - the default message category of the validator message that will be displayed; the default is $MSG_ERROR |
Functions Returning Integers
int checkString(int exp flags, string exp string)
| • | flags - can be added together |
| • | 1 - returns TRUE if string has leading space characters |
| • | 2 - returns TRUE if string has ending space characters |
| • | 4 - returns TRUE if string appears to be an absolute URL missing a protocol; v4.50 replaces character references and URL decodes before checking; v8.00 has improved detection and sets $checkstring4domain if returns TRUE |
| • | 8 - returns TRUE if string begins with a letter (A-Z or a-z) and consists of the following characters: (A-Z), (a-z), (0-9), hyphens (-), underscores (_), colons (:), or periods (.) |
| • | 16 - returns TRUE if string begins with a letter (A-Z or a-z) |
| • | 32 - returns TRUE if string contains any collapsed PHP, ASP, etc. code. (looks for strings like "PHP", "ASP", and "MIVA" in string and returns TRUE if it finds it) (New v4.0330) |
| • | 64 - returns TRUE if string ends in a '#' character (not considering trailing spaces) and string does not contain more than one '#' character (New v4.0410) |
| • | 128 - returns TRUE if string contains a '#' character that is surrounded by one or more spaces and string does not contain more than one '#' character (New v4.0410) |
| • | 256 - returns TRUE if string appears to be an internal link (starts with the character '#' and does not contain more than one '#' character) (New v4.0410) |
| • | 512 - returns TRUE if string appears to be a valid email address (ignores the '?' character and everything after it); as of v6.01, if returning FALSE, then sets 1) $checkstring512details with details about the incorrect syntax, 2) $checkstring512detailsnumchecked with the number of email addresses checked (new v6.50), and 3) $checkstring512detailsqmarkindex with the index of the first occurance of the character '?' based on the last checked email address (new v6.50); as of v6.01, works with multiple email addresses separated by commas NOTE: Always returns TRUE if email address syntax checking has been disabled. (New v4.05) |
| • | 1024 - use with 512; ignores any "mailto:" prefix in string when checking for a valid email address (New v4.05) |
| • | 2048 - returns TRUE if the string contains any spaces (New v4.5000) |
| • | 4096 - returns TRUE if a '%' character is found that is not followed by two hexadecimal digits (New v4.5000) |
| • | 8192 - returns TRUE if string consists only of lowercase characters, numbers, backslashes, and underscore characters, and has a maximum of one colon and one period (New v4.5021) |
| • | 16384 - returns TRUE if string consists only of lowercase characters, numbers, and underscore characters, and has a maximum of one period (New v4.5022) |
| • | 32768 - returns the number of possible misspellings in string and adds the possibly misspelled words to the list of possibly misspelled words (New v4.5091) |
| • | 65536 - use with 512; URL decode (percent-decode) email address before checking (New v7.9914) |
| • | string - the string to check |
| • | The default return value is 0 unless it is changed due to a flag. |
| • | This function is implemented only in CSE HTML Validator Std/Pro v4.0320 and later. |
int checkStringEx(int exp flags, int exp mode,
string exp string)
| • | flags - can be added together; the flags value depends on mode so see the values for mode below for available flags; if a mode does not say anything about flags, then the flags value is not used and should be 0. |
| • | mode - can not be added together |
| • | 1 - return TRUE if string is a valid charset like "iso-8859-1" |
| • | 2 - return TRUE if string ends with a comma (disregarding trailing whitespace) (New v5.0200) |
| • | 3 - return TRUE if string appears to be a valid "lang" attribute value (New v5.4910) |
| • | 4 - return TRUE if string begins with a '#' character (disregards preceding whitespace) (New v5.4910) |
| • | 5 - return TRUE if string contains two or more adjacent hyphens (use for checking comments; excludes beginning "!--" and ending "--", returns FALSE if string begins with "!--#"); if returns TRUE then use getLocation(5,0) to get location of hyphens (New v5.4910) |
| • | 6 - return TRUE if string ends in "--" followed by one or more spaces (New v5.4910) |
| • | 7 - return the number of words in string (New v5.4930) |
| • | 8 - return the number of repeated words/phrases given a comma separated list in string; a list of repeated words/phrases is stored in $repeatedlist; the number of "empty" words is stored in $numemptywords (New v5.4940) |
| • | 9 - returns TRUE if string is a percent, else returns FALSE (New v5.4940) |
| • | 10 - returns TRUE if string contains only digits 0-9 (must contain at least one digit), else returns FALSE; flags below (New v5.5100) |
| • | 1 - allow leading whitespace |
| • | 2 - allow trailing whitespace |
| • | 4 - allow an optional preceeding '-' character |
| • | 8 - require preceeding '-' character |
| • | 16 - allow zero or one '.' characters |
| • | 32 - require one '.' character |
| • | 64 - allow an optional ending '%' character |
| • | 128 - require ending '%' character |
| • | 256 - instead of returning TRUE or FALSE, return one of following values |
| • | 1 - value is a percent >100% (only if flag 512 set) |
| • | -1 - miscellaneous reason why value is not OK |
| • | -2 - misplaced or multiple '-' characters |
| • | -3 - multiple '.' characters |
| • | -4 - missing required '-' character |
| • | -5 - missing required '.' character |
| • | -6 - missing required '%' character |
| • | -7 - contains unallowed character or bad format |
| • | -8 - contains no digits (must contain at least 1) |
| • | 512 - use with flag 256 to allow a return value of 1 |
| • | 11 - returns TRUE if string contains only whitespace characters (one or more), else returns FALSE (New v5.9910) |
| • | 12 - returns TRUE if string is an index page (such as "index.htm", "index.html", "index.php", "index.asp") or if the string ends in a "/" followed by an index page, else returns FALSE (New v5.9910) |
| • | 1 - if returning TRUE, then create variables $checkstringex12docname (contains "index.htm", "index.php", etc) and $checkstringex12recommendedurl (contains the recommended replacement URL) |
| • | 13 - returns TRUE if string contains a semicolon and period but no comma between two '@' characters, else returns FALSE (used for checking mailto links with multiple email addresses that could incorrectly be separated with semicolons instead of commas) (New v6.4930) |
| • | 14 - returns TRUE if string contains optional whitespace followed by optional digits (0-9) followed by optional whitespace followed by a CSS length unit, else returns FALSE; if returns TRUE, then the length unit is stored in $checkstringex14unit (New v6.4930) |
| • | 15 - returns TRUE if string appears to contain mismatched double or single quotation marks, else returns FALSE (New v6.4940) |
| • | 1 - only check if value is <=100 characters |
| • | 16 - returns TRUE if string appears to contain improper backslashes instead of forward slashes (use for checking links) (New v6.9921) |
| • | 17 - returns TRUE if string appears to contain an improper double slash sequence (use for checking links) (New v6.9931) |
| • | 18 - returns the number of commas in string (New v7.0000) |
| • | 19 - returns TRUE if string is recognized as a web-safe typeface; if there are no recognized web-safe typefaces (if the list of recognized web-safe typefaces has been cleared), then will always return TRUE (New v8.00) |
| • | 20 - checks a comma separated list of typefaces in string and returns FALSE if any of them are not recognized as "web-safe", which means that they may not be available on a significant number of browsers; else returns TRUE; if returns FALSE, then a list of the unrecognized typefaces is available in $checkstringex20list (with $checkstringex20listnum containing the number of typefaces in the list) and a complete list (including ignored typefaces) is available in $checkstringex20list2 (with $checkstringex20list2num containing the number of typefaces in the list). NOTE: Once a typeface is recognized as not web-safe, it is ignored in further calls to this function for the duration of the validation. This is to prevent the same typeface being used multiple times from generating more than one validator message. You can add to the recognized list of web-safe typefaces using setValueString(10,typeface name) in the onConfigLoad() function. flags below |
| • | 1 - do not consider ignored typefaces from previous calls when returning TRUE or FALSE |
| • | 2 - do not use; this flag used internally |
| • | 21 - checks a comma separated list of typefaces in string and returns FALSE if there are any unrecognized typefaces or if typefaces from more than one family were specified. If returns FALSE, then sets $checkstringex21msg with the text of a message to display, $checkstringex21numunrec with the number of unrecognized typefaces, and $checkstringex21msgtype with the recommended message type (regular message if there were no unrecognized typefaces or a warning message type if there were unrecognized typefaces). NOTE: Once a typeface is not recognized, it is ignored in further calls to this function for the duration of the validation. This is to prevent the same typeface being used multiple times from generating more than one validator message about it. You can add to the recognized list of typefaces using setValueString(11,typeface name) in the onConfigLoad() function. flags below |
| • | 2 - do not use; this flag used internally |
| • | 22 - returns TRUE if string contains a Sitestepper variable and Sitestepper integration is on (New 8.0200) |
| • | string - the string to check |
| • | The default return value is 0 (FALSE) unless it is changed due to a valid mode. |
| • | This function is implemented only in CSE HTML Validator Std/Pro v4.9910 and later. |
int checkVersion(float exp version)
| • | version - the minimum version of the validator required for the function to return 1 |
| • | Returns 1 if using HTML Validator version version or greater, else the function returns 0. |
| • | Use this to help make sure that the procedures and functions that are being used are valid for the version of CSE HTML Validator that is executing them. |
int getAttIndex(string exp attribute)
| • | attribute - the attribute in the tag to search for |
| • | Returns the index of the attribute. If the attribute does not exist, then the function returns 0. For example, if the attribute exists and is the first attribute for the tag, then the function returns 1. |
int getNumAttributes()
| • | Returns the number of attributes for the current tag. |
int getStringStartIndex(string exp string1, string exp string2)
| • | Searches for string2 in string1 and returns the index into string1 where string2 starts. |
| • | The index is 0 based. For example, if string2 is contained in the very beginning of string1, then the function returns 0. |
| • | If string2 is not in string1, then the function returns -1. |
| • | Performs a case insensitive search. |
| • | This function is implemented only in CSE HTML Validator Std/Pro v3.03 and later. |
int getValueInt(int exp valueidentifier)
| • | valueidentifier - tells the function which value to return |
| • | 1 - the current number of error messages generated |
| • | 2 - the current number of warning messages generated |
| • | 3 - the current number of message messages generated |
| • | 4 - the current number of comment messages generated |
| • | 5 - returns 1 if compiled for a "normal" build (not an OEM version), else returns another value |
| • | 6 - returns 1 if running from command line arguments, else returns 0 |
| • | 7 - returns 1 if processing a batch (for example, called with cmdlineprocessor.exe -f), else returns 0 |
| • | 8 - returns the number of lines in the document (New v4.00) |
| • | 9 - returns the number of elements (tags) in the document (New v4.00) |
| • | 10 - returns the number of elements (tags) that have been ended (with an end tag) (New v4.00) |
| • | 11 - returns the number of HTML comments in the document (New v4.00) |
| • | 12 - returns the number of entities in the document (New v4.00) |
| • | 13 - returns the number of tag name programs run (New v4.00) |
| • | 14 - returns 1 if the validator is generating an easily parsed output file (usually used when integrating with other applications), else returns 0 (New v4.00) |
| • | 15 - returns 1 if the validator is validating a file in CSE's integrated editor (not in classic mode), else returns 0 (New v4.00) |
| • | 16 - returns 1 if the validator is validating a file in CSE's integrated editor (whether in classic mode or not), else returns 0 (New v4.00) |
| • | 17 - returns the number of bytes in the document (each newline is considered 1.5 bytes) (New v4.0012) |
| • | 18 - returns 1 if the validator is validating a file in the Batch Wizard, else returns 0 (New v4.02) |
| • | 19 - returns 1 if there have been too many errors or warnings and the validation is being terminated (New v4.5021) |
| • | 20 - returns CSEJOBSUBTYPE (New v4.5091) |
| • | 21 - returns the attribute index for attribute programs or attribute value programs (should be >=1)(New v4.5091) |
| • | 22 - returns doctypeflags (contains information about the DOCTYPE being used) (New v4.5110) |
| • | 1 - DOCTYPE is empty string |
| • | 2 - DOCTYPE contains "strict" (case insensitive) |
| • | 4 - DOCTYPE contains "transitional" (case insensitive) |
| • | 8 - DOCTYPE contains "frameset" (case insensitive) |
| • | 16 - DOCTYPE contains "HTML 4.0" or "HTML 4.01" (case insensitive) |
| • | 32 - DOCTYPE contains "XHTML" (case insensitive) |
| • | 64 - DOCTYPE contains "XHTML 1.1" (case insensitive) (New v5.0200) |
| • | 128 - DOCTYPE contains "XHTML 1.0" (case insensitive) (New v5.0200) |
| • | 256 - DOCTYPE contains "HTML" (case insensitive) (New v5.4910) |
| • | 512 - DOCTYPE contains "XHTML Basic" (case insensitive) (New v5.4920) |
| • | 1024 - Document has no DOCTYPE (or the DOCTYPE hasn't been set/encountered yet) (New v5.4930) |
| • | 2048 - DOCTYPE contains "HTML 3.2" (case insensitive) (New v5.9910) |
| • | 4096 - DOCTYPE contains "HTML 3.0" (case insensitive) (New v5.9910) |
| • | 8192 - DOCTYPE contains "HTML 2.0" (case insensitive) (New v5.9910) |
| • | 16384 - DOCTYPE contains " HTML 4.0" followed by a non-digit (case insensitive) (New v6.4930) |
| • | 32768 - DOCTYPE contains " HTML 4.01" (case insensitive) (New v6.4930) |
| • | 65536 - DOCTYPE contains "HTML" but not "XHTML" (case insensitive) (New v6.4930) |
| • | Only one or none of the following flags will be set: 16, 2048, 4096, 8192 |
| • | 23 - returns the number of characters of the text content of the tag that is being closed; preceding and trailing spaces are not considered; stores the text content (preceding and trailing spaces, if any, are removed) in a variable named getvalueint23content; use in a tag close program only (New v5.4930) |
| • | 24 - returns 1 if checking an external style sheet, else returns 0 (New v5.4930) |
| • | 25 - returns 1 if the current tag is closed with "/>", else returns FALSE; use in a tag name open program, attribute program, or attribute value program only (New v5.5100) |
| • | 26 - returns 1 if accessibility checking is enabled else returns 0 (New v5.9910) |
| • | 27 - returns 1 if WCAG 1.0 accessibility checking is enabled else returns 0 (New v5.9910) |
| • | 28 - returns 1 if Section 508 accessibility checking is enabled else returns 0 (New v5.9910) |
| • | 29 - returns 1 if both accessibility checking and WCAG 1.0 accessibility checking are enabled else returns 0 (New v5.9910) |
| • | 30 - returns 1 if both accessibility checking and Section 508 accessibility checking are enabled else returns 0 (New v5.9910) |
| • | 31 - returns 1 if the enable sound option is checked else returns 0 (New v5.9920) |
| • | 32 - returns the number of CDATA sections in the document (New v5.9920) |
| • | 33 - returns 1 if WCAG Priority 1 messages should be displayed, else returns 0 (New v5.9930) |
| • | 34 - returns 1 if WCAG Priority 2 messages should be displayed, else returns 0 (New v5.9930) |