CSS HTML Validator 2019/v19 and later releases are native 64-bit and include 64-bit csevalidator-x64.dll. Version 19.0010 and later also include 32-bit csevalidator.dll for backward compatibility.
NOTE: The developer information and documentation is ongoing. If you believe that there is anything missing or inaccurate then please contact us.
The functions and their parameters available in csevalidator[-x64].dll are specified in the csevalidator.h file that should be included with projects that you create that will use this DLL. csevalidator.h contains a lot of needed information that is not available in this documentation because it is in csevalidator.h. This includes all available functions and their parameters and many constants (#defines) needed to interact with the functions. If you are dynamically linking the DLL and using C/C++, you may also find csefunctionpointerassign.cpp useful.
Starting with CSE HTML Validator 8.0, strings are now handled internally as wide strings (UTF-16). Therefore, equivalent functions with wide string support are now available in the DLL and should be used whenever possible, although the older non-wide string functions are still available. These wide string functions are just like the non-wide string functions but the function name ends in "W". For example, instead of
CSESetStringW() whenever possible.
The integration works very much the same between editions. You can allow your users to switch editions (and/or versions) by allowing them to specify which CSS HTML Validator DLL they want to use, although doing this should not be needed as there will usually only be one version and edition of CSS HTML Validator that the user is using.
We recommend that you design the integration of CSS HTML Validator with your application using the professional edition and linking to the DLL dynamically. To support the lite edition, just use the lite edition DLL instead of the std/pro DLL. You'll get different validation results from the DLL, but the interface to each edition's DLL is the same. Some features may not be supported in the lite edition, and if you call an unsupported function, then the return value may indicate specifically that it is not supported, or it will just appear to work without problems. In any case, all DLL editions are designed to be easily interchangeable.
You generally make the validator available to your users in the following manner:
You generally use the validator in the following manner:
Instance=LoadLibrary("c:\\path\\to\\csevalidator.dll")). After loading the library, obtain function pointers to the validator DLL functions. NOTE: To mitigate DLL hijacking risks, always use the full path to the DLL. See finding csevalidator[-x64].dll.
CSEGetHandle()and loading the program configuration and HTML configuration using this handle. When you tell CSS HTML Validator to perform a job, you must give it a configuration handle that it uses to perform the job. This tells the validator how to perform the job with regards to the options that are configurable. It also includes the HTML configuration which tells CSS HTML Validator the syntax rules of the document it is checking. An HTML configuration is required and must be loaded into any configuration handle that will be used to check a document's syntax.
CSEGetHandle(). You then set up the job using the job handle and other functions such as
CSERunJob()with the configuration and job handles. This function performs the job and passes back a result handle that you can use to obtain the results of the job, usually by calling functions such as the
Before using csevalidator[-x64].dll, you must first be able to load it.
In addition to the below, which explains how to find the DLL automatically, consider an option in your program that lets a user specify the exact location of the version and edition of the CSS HTML Validator DLL that he/she would like to use.
Instance=LoadLibrary("csevalidator.dll")). If the return value (Instance) is not 0, then you've successfully accessed the DLL (of the last version and edition of CSS HTML Validator that was installed with administrator privileges) and should not need to perform other methods to try to locate it. This method will normally work if a user has installed a compatible version of CSS HTML Validator on their system. If this fails and the user did install CSS HTML Validator, then the installer may not have has access to install the DLL in the Windows system folder. In this case, the program will be installed, but the DLL may not be easily accessible unless you first find out where it is installed on the user's system (since it will not be installed in the system folder due to access/permission issues). If you cannot load the library with
LoadLibrary()then you may want to stop here (see below for what to do when the library can't be loaded). However, you may optionally choose to try to find the DLL via another method (some suggestions below) and then call
LoadLibrary()again with the full path to the DLL.
General information on using the functions:
CSESetString()for each line of the input file.
Before HTML Validator can perform a job, you must set up a configuration by obtaining at least one configuration handle. How to initialize and obtain a configuration handle:
CSEGetNewHandle(CSEGETNEWHANDLECFG | CSEGETNEWHANDLEREGISTRYLOAD). The handle returned by this function will be called "confighandle".
CSEHTMLConfiguration(NULL, confighandle, CSEHTMLCONFIGURATIONLOAD).
Before performing a job, you must get a job handle and then set-up the job. How to obtain a job handle and set it up:
CSEGetNewHandle(CSEGETNEWHANDLEJOB). The handle returned by this function will be called "jobhandle".
CSESetInteger(jobhandle, CSEJOBTYPE, jobtype), where jobtype is a CSEJOBTYPExxx define from csevalidator.h.
CSESetInteger(jobhandle, CSEJOBSOURCE, jobsource), where jobsource is a CSEJOBSOURCExxx define from csevalidator.h. CSEJOBSOURCEBUFFER is the default.
CSESetInteger(jobhandle, CSEJOBRESETBUFFER, 0).
CSESetString(jobhandle, CSEJOBADDLINETOBUF, line), where line is a const char * to the line to add.
CSESetString(jobhandle, CSEJOBINFILENAME, filename).
CSESetFlag(jobhandle, CSEJOBFLAGS, CSEJOBFLAGOUTPUTTOFILE, 1)and set the filename to write to by calling
CSESetString(jobhandle, CSEJOBOUTFILENAME, filename). The default is only to write to the result buffer.
How to run a job and obtain a results handle:
CSERunJob(NULL, confighandle, jobhandle, 0). If the validator successfully completes the job (excluding minor errors and problems), a result handle, that is 0 or greater, is created and returned. Note that you do not need to pass a result handle to
CSERunJob()as it creates on itself. If a serious error occurred preventing the job from running, a negative number is returned that indicates the error and no result handle is created or returned. The handle returned by this function will be called "resulthandle".
CSERunJob()to get information about the job. For instance, to obtain the message information from a validation job:
CSEGetInteger(resulthandle,CSERESULTNUMERRORS). You may also use CSERESULTNUMWARNINGS, CSERESULTNUMMESSAGES, and CSERESULTNUMCOMMENTS.
CSEGetInteger2(resulthandle, CSERESULTMSGTYPE, 3). The return value is the value of a CSEMSGTYPExxx define that indicates if the message is an error, warning, message, or comment.
CSEGetString2(resulthandle, CSERESULTMSGTEXT, 1). To get the second message's text, call
CSEGetString2(resulthandle, CSERESULTMSGTEXT, 2).
CSEGetInteger(resulthandle, CSERESULTMSGLINELOC, 5).
CSEGetInteger2EZ(resulthandle, CSERESULTMSGCHARLOC, 5). To get how many characters, call
CSEGetInteger2EZ(resulthandle, CSERESULTMSGCHARLOCLENGTH, 5)
CSEGetNumberOfHandles(0). Use this to monitor your program for memory leaks caused by not freeing handles.
Opening/using the Validator Engine Options:
CSEOpenValidatorOptions(hwnd, confighandle, flags). hwnd can be NULL.
CSEWriteToRegistry(hwnd, confighandle, 0)to save (to the registry) the current options in memory so that the options can be reloaded the next time that the validator DLL is initialized. You can do this before unloading or freeing the validator DLL or at any time.
Opening/using the HTML Configuration Editor:
CSEOpenConfigurationEditor(hwnd, confighandle, 0). hwnd can be NULL.
CSEHTMLConfiguration(hwnd, confighandle, CSEHTMLCONFIGURATIONASKSAVE)is called before unloading or freeing the validator DLL. This will ask the user if he or she wants to save the HTML configuration if it has changed. Using this flag, the return values are:
CSEHTMLConfiguration()are listed in csevalidator.h.
Getting version/edition information
CSEGetInteger3EZ(CSEPROGRAMVERSIONINT). This will return the version number*10000. For example, for version 6.5301, it will return 65301 and for 2019/v19.0013, it will return 190013.
CSEGetInteger3EZ(CSEPROGRAMVERSIONINT) >= 70000. If the version is 7.0 or higher, then
CSEGetInteger3EZ(CSEPROGRAMEDITION)may be used to get the edition. It will return 1 for the professional edition, 2 for the standard edition, or 3 for the lite edition.