| » Metadata |
» Status |
|
|
|
| » Description |
Provides an OO interface to the API of the W3C CSS Validator application (http://jigsaw.w3.org/css-validator/). 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 style sheet.
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://jigsaw.w3.org/css-validator/api.html .
URI validation
<?php
require_once 'Services/W3C/CSSValidator.php';
$v = new Services_W3C_CSSValidator();
$r = $v->validateUri('http://pear.php.net');
if ($r->isValid()) {
echo 'StyleSheets used in web page are valid!';
}
?>
CSS upload file validation
<?php
require_once 'Services/W3C/CSSValidator.php';
$v = new Services_W3C_CSSValidator();
$r = $v->validateFile('pear_manual.css');
echo '<pre>';
var_dump($r));
echo '</pre>';
?>
Will return:
object(Services_W3C_CSSValidator_Response)[7]
public 'uri' => string 'file://localhost/pear_manual.css' (length=32)
public 'checkedby' => string 'http://jigsaw.w3.org/css-validator/' (length=35)
public 'csslevel' => string 'css21' (length=5)
public 'date' => string '2007-09-29T05:06:20Z' (length=20)
public 'validity' => boolean true
public 'errors' =>
array
empty
public 'warnings' =>
array
empty
CSS fragment code validation
<?php
require_once 'Services/W3C/CSSValidator.php';
$v = new Services_W3C_CSSValidator();
$r = $v->validateFragment('ul.man-side_top,
ul.man-side_up,
ul.man-side_download {
margin-top: 0.5e;
margin-bottom: 0.5em;
margin-left: 0.7em;
padding-left: 0.7em;
}');
echo '<pre>';
var_dump($r);
echo '</pre>';
?>
Will return:
object(Services_W3C_CSSValidator_Response)[7]
public 'uri' => string 'file://localhost/TextArea' (length=25)
public 'checkedby' => string 'http://jigsaw.w3.org/css-validator/' (length=35)
public 'csslevel' => string 'css21' (length=5)
public 'date' => string '2007-10-02T06:31:36Z' (length=20)
public 'validity' => boolean false
public 'errors' =>
array
0 =>
object(Services_W3C_CSSValidator_Error)[12]
public 'errortype' => string 'parse-error' (length=11)
public 'context' => string 'ul.man-side_top, ul.man-side_up, ul.man-side_download' (length=53)
public 'property' => string 'margin-top' (length=10)
public 'uri' => null
public 'line' => string '4' (length=1)
public 'message' => string 'Unknown dimension' (length=17)
public 'warnings' =>
array
empty
Credits, Origin
I would like to give a special thank to Brett Bieber and his proposal/package Services_W3C_HTMLValidator.
Services_W3C_CSSValidator is no more no less than an adaptation of Services_W3C_HTMLValidator from W3C HTML Service Validation to W3C CSS Service Validation.
Idea to make this package come from a bug report #12039 on one of my maintained packages (HTML_CSS).
I think it could be a great help to HTML_CSS package to ensure user-data in are valid before to parse sources. |
| » Dependencies |
» Links |
|
|
|
| » Timeline |
» Changelog |
-
First Draft: 2007-09-29
- Proposal: 2007-10-03
- Call for Votes: 2007-10-22
|
|