Proposal for "Services_W3C_HTMLValidator"

» Metadata » Status
  • Category: Web Services
  • Proposer: Brett Bieber 
  • License: BSD Style
» Description
Provides an OO interface to the API of the W3 HTML Validator application (http://validator.w3.org/). With this package you can connect to a running instance of the validator and retrieve the validation results (true|false) as well as the errors and warnings for a web page.

It utilizes the SOAP1.2 output format for the validator to obtain results and populate simple objects for the results.

For more information see http://validator.w3.org/docs/api.html

A simple example:

<?php
require_once 'Services/W3C/HTMLValidator.php';
$v = new Services_W3C_HTMLValidator();
$res = $v->validate('http://pear.unl.edu/');
if ($res->isValid()) {
echo 'Valid!';
}
?>


Detailed results are also available:

<?php
require_once 'Services/W3C/HTMLValidator.php';

$v = new Services_W3C_HTMLValidator();
echo '<pre>';
var_dump($v->validate('http://pear.unl.edu/'));
?>


Will return:

object(Services_W3C_HTMLValidator_Response)#7 (7) {
["uri"]=>
string(20) "http://pear.unl.edu/" /> ["checkedby"]=>
string(24) "
http://validator.w3.org/" /> ["doctype"]=>
string(38) "-//W3C//DTD XHTML 1.0 Transitional//EN"
["charset"]=>
string(5) "utf-8"
["validity"]=>
bool(true)
["errors"]=>
array(0) {
}
["warnings"]=>
array(0) {
}
}


Updated 2006-12-03:
Added validateFragment($html) to validate a string of html content.
Added validateFile($file) for validating uploaded documents.
Add method to response object isValid().
Add examples for validateFile and validateFragment
Correct CS and phpdoc errors (thx David Coallier/CPUnerd).

Updated 2006-12-05:
Switched methods from private to protected to allow overriding.
Move all variables which were int 0|1 to booleans (thanks Christian Weiske).
» Dependencies » Links
  • HTTP_Request
» Timeline » Changelog
  • First Draft: 2006-11-28
  • Proposal: 2006-11-28
  • Call for Votes: 2006-12-05
  • Brett Bieber
    [2006-12-04 04:21 UTC]

    Added validateFragment($html) to validate a string of html.
    Added validateFile($file) for validating uploaded documents.
    Add method to response object isValid().
    Add examples for validateFile and validateFragment.
    Correct CS and phpdoc errors (thx David Coallier/CPUnerd).

    Will call for votes soon, please comment if interested.
  • Brett Bieber
    [2006-12-05 21:17 UTC]

    Switched methods from private to protected to allow overriding.
    Move all variables which were int 0|1 to booleans (thanks Christian Weiske).