Validator User Functions: Writing a header

For technical support and bug reports for all editions of CSS HTML Validator, including htmlval for Linux and Mac.
Post Reply
User avatar
MikeGale
Rank VI - Professional
Posts: 726
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Validator User Functions: Writing a header

Post by MikeGale »

Hi,

I'm writing a file with content created in "onMessageAdded" events.

I'd like to add a header row as the first entry in that file.

Which event should I use to do that? (I've tried onStartValidation and find that some comments are added before this event fires.)
User avatar
Albert Wiersch
Site Admin
Posts: 3785
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Validator User Functions: Writing a header

Post by Albert Wiersch »

Hi Mike,

I see that onStartValidation() was being called after some potential messages were generated and I've changed it so that onStartValidation() is called sooner. Do you know what message was being generated before onStartValidation()? If I know the exact message then I can verify this problem is fixed.

Also, it is far more efficient to 'write to an array' and then write the array to a file in onEndedValidation(). There, you can check that the file exists and write the column headers if not.

This example writes appends an array to a file but first makes sure that the file exists. If the file doesn't exist then it creates the file with column headers.

Code: Select all

function onEndedValidation() {
 $outfilename='C:\CSEValidator-output\validation_output.csv';
 if !existsFile($outfilename) { // write column headers if file doesn't exist
  writeFile($outfilename,'col1,col2,col3,col4,col5',1);
 }
 writeFile($outfilename,$csvfilearray,1); // append contents of array
}
Albert Wiersch, CSS HTML Validator Developer • Download CSS HTML Validator FREE Trial
User avatar
MikeGale
Rank VI - Professional
Posts: 726
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Re: Validator User Functions: Writing a header

Post by MikeGale »

The messages that precede the header (in one test) are

Code: Select all

http://www.decisionz.com/	COMMENT	Accessibility	-1	-1	2002071591	Section 508 accessibility checking is disabled.		
http://www.decisionz.com/	COMMENT	Accessibility	-1	-1	2002071591	WCAG 1.0 accessibility checking is disabled.		
http://www.decisionz.com/	COMMENT	Accessibility	-1	-1	2009082702	WCAG 2.0 accessibility checking is disabled.		
http://www.decisionz.com/	COMMENT	Accessibility	-1	-1	2003011600	Accessibility checking is not enabled. This program can help you make your web pages more accessible. An accessible page is one that more individuals can use, such as individuals who are blind or deaf. It can also increase the usefulness of your web page for individuals who browse the web using slower devices like older computers or wireless devices like mobile phones and PDAs. An accessible web site makes good business sense (and possibly good legal sense as well) and may even improve search engine rankings. You can enable or disable accessibility checking in the Validator Engine Options.		
I am writing an array to the file.

I implemented a solution, but I like the look of yours and may replace it. Thanks
Post Reply