ColdFusion HTML Validation Library

January 2, 2008 at 1:12 am Leave a comment


We’ve created a ColdFusion library to perform HTML Validation through http://validator.w3.org/ it allows you to programmatically query http://validator.w3.org/ for invalid markup (HTML, XHTML, …).

We’re publishing the code to the public, anyone interested in downloading the ColdFusion classes can send us an email on coldfusion_html_validator@clickfind.com.au once our sourceForge.net account is approved we’ll host the code there.

Example code:

<cfscript>
HTMLValidator = createObject( “component”, application.object.root & “._resource.class.HTMLValidator” ). init( “http://www.clickfind.com.au/” );
</cfscript>
<cfoutput>
<h1>#HTMLValidator.getURI()#</h1>
<p>
Has error: #HTMLValidator.hasError()#<br>
Number of errors: #HTMLValidator.getErrorCount()#<br>
Has warning: #HTMLValidator.hasWarning()#<br>
Number of warnings: #HTMLValidator.getWarningCount()#
 </p>
 <cfscript>
Iterator = HTMLValidator.getErrorCollection();
writeOutput( “<h2>Errors</h2>” );
while( Iterator.hasNext() ) {
ValidationMessage = Iterator.getNext();
writeOutput( “<p>” );
writeOutput( “Line: ” & ValidationMessage.getLine() & “<br>” );
writeOutput( “Col: ” & ValidationMessage.getCol() & “<br>” );
writeOutput( “Message: ” & ValidationMessage.getMessage() & “<br>” );
writeOutput( “Message id: ” & ValidationMessage.getMessageId() & “<br>” );
writeOutput( “Explanation: ” & ValidationMessage.getExplanation() & “<br>” );
writeOutput( “Source: ” & ValidationMessage.getSource() );
writeOutput( “</p>” );
}
Iterator = HTMLValidator.getWarningCollection();
writeOutput( “<h2>Warnings</h2>” );
while( Iterator.hasNext() ) {
ValidationMessage = Iterator.getNext();
writeOutput( “<p>” );
writeOutput( “Line: ” & ValidationMessage.getLine() & “<br>” );
writeOutput( “Col: ” & ValidationMessage.getCol() & “<br>” );
writeOutput( “Message: ” & ValidationMessage.getMessage() & “<br>” );
writeOutput( “Message id: ” & ValidationMessage.getMessageId() & “<br>” );
writeOutput( “Explanation: ” & ValidationMessage.getExplanation() & “<br>” );
writeOutput( “Source: ” & ValidationMessage.getSource() );
writeOutput( “</p>” );
}
</cfscript>
</cfoutput>

We are currently using this functionality ourselves on www.clickfind.com.au under “My account”, it allows customers to check their site for validation errors.

Any comments or feedback is welcome.

Advertisements

Entry filed under: ColdFusion. Tags: , , , , .

End of year search engine statistics Google Spell check (spellcheck)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 19 other followers

Archives

Top Rated

Top Clicks

  • None

Blog Stats

  • 169,146 hits

%d bloggers like this: