1WebService::Validator::UCsSeSr::CWo3nCt(r3i)buted Perl DWoecbuSmeernvtiactei:o:nValidator::CSS::W3C(3)
2
3
4

NAME

6       WebService::Validator::CSS::W3C - Interface to the W3C CSS Validator
7

SYNOPSIS

9         use WebService::Validator::CSS::W3C;
10
11         my $css = "p { color: not-a-color }";
12         my $val = WebService::Validator::CSS::W3C->new;
13         my $ok = $val->validate(string => $css);
14
15         if ($ok and !$val->is_valid) {
16             print "Errors:\n";
17             printf "  * %s\n", $_->{message}
18               foreach $val->errors
19         }
20

DESCRIPTION

22       This module is an  interface to the W3C CSS Validation online service
23       http://jigsaw.w3.org/css-validator/ <http://jigsaw.w3.org/css-
24       validator/>, based on its SOAP 1.2 support.  It helps to find errors in
25       Cascading Style Sheets.
26
27       The following methods are available:
28
29       my $val = WebService::Validator::CSS::W3C->new
30       my $val = WebService::Validator::CSS::W3C->new($ua)
31       my $val = WebService::Validator::CSS::W3C->new($ua, $url)
32           Creates a new WebService::Validator::CSS::W3C object. A custom
33           LWP::UserAgent object can be supplied which is then used for HTTP
34           communication with the CSS Validator. $url is the URL of the CSS
35           Validator, "http://jigsaw.w3.org/css-validator/validator" by
36           default.
37
38       my $success = $val->validate(%params)
39           Validate a style sheet, takes %params as defined below. Either
40           "string" or "uri" must be supplied. Returns a true value if the
41           validation succeeded (regardless of whether the style sheet
42           contains errors).
43
44           string => $css
45               A style sheet as a string. It is currently unlikely that
46               validation will work if the string is not a legal UTF-8 string.
47               If a string is specified, the "uri" parameter will be ignored.
48               Note that "GET" will be used to pass the string to the
49               Validator, it might not work with overly long strings.
50
51           uri => $uri
52               The location of a style sheet or a HTML/XHTML/SVG document
53               containing or referencing style sheets.
54
55           medium => "print"
56               The medium for which the style sheet should apply, one of
57               "aural", "braille", "embossed", "handheld", "print", "screen",
58               "tty", "tv", and "presentation".  A special value "all" can
59               also be specified. The default is "undef" in which case the CSS
60               Validator determines a value; this would currently be as if
61               "all" had been specified.
62
63           profile => "css3"
64               The CSS Version or profile to validate against, legal values
65               are "css1", "css2", "css21", "css3", "svg", "svgbasic",
66               "svgtiny", "mobile", "atsc-tv", and "tv". A special value
67               "none" can also be used. The default is "undef" in which case
68               the CSS Validator determines a default. This would currently
69               behave as if "css2" had been specified.
70
71           warnings => 2
72               An integer 0 - 10 that determines how many warning messages you
73               want to get back from the CSS Validator, 0 means no warnings,
74               10 would give most warnings, but is currently effectively the
75               same as 1. The defaut is "undef" in which case the CSS
76               Validator determines a default value; this is expected to be as
77               if 2 had been specified.
78
79           language => "de"
80               The desired language of the supposedly human-readable messages.
81               The string will passed as an "Accept-Language" header in the
82               HTTP request. The CSS Validator currently supports "en", "de",
83               "fr", "ja", "nl", "zh", and "zh-cn".
84
85       my $success = $val->success
86           Same as the return value of "validate()".
87
88       my $is_valid = $val->is_valid
89           Returns a true value if the last attempt to "validate()" succeeded
90           and the validator reported no errors in the style sheet.
91
92       my $num_errors = $val->errorcount
93           returns the number of errors found for the checked style sheet.
94           Get the details of the errors with $val->errors (see below).
95
96       my @errors = $val->errors
97           Returns a list with information about the errors found for the
98           style sheet. An error is a hash reference; the example in the
99           synopsis would currently return something like
100
101             ( {
102               context    => 'p',
103               property   => 'color',
104               expression => { start => '', end => 'not-a-color' }
105               errortype  => 'parse-error',
106               message    => 'not-a-color is not a color value',
107               line       => 0,
108             } )
109
110       my $num_warnings = $val->warningcount
111           returns the number of warnings found for the checked style sheet.
112           Get the details of each warning with $val->warnings (see below).
113
114       my @warnings = $val->warnings
115           Returns a list with information about the warnings found for the
116           style sheet. This is currently of limited use as it is broken, see
117           <http://www.w3.org/Bugs/Public/show_bug.cgi?id=771> for details.
118
119           @@example
120
121       my $ua = $val->user_agent
122       my $ua = $val->user_agent($new_ua)
123           The LWP::UserAgent object you supplied to the constructor or a
124           custom object created at construction time you can manipulate.
125
126             # set timeout to 30 seconds
127             $val->user_agent->timeout(30);
128
129           You can also supply a new object to replace the old one.
130
131       my $uri = $val->validator_uri
132       my $uri = $val->validator_uri($validator_uri)
133           Gets or sets the URI of the validator. If you did not specify a
134           custom URI, "http://jigsaw.w3.org/css-validator/validator" by
135           default.
136
137       my $response = $val->response
138           The HTTP::Response object returned from the last request. This is
139           useful to determine why validation might have failed.
140
141             if (!$val->validate(string => $css)) {
142               if (!$val->response->is_success) {
143                 print $val->response->message, "\n"
144               }
145             }
146
147       my $uri = $val->request_uri
148           The URI object used for the last request.
149
150       my $som = $val->som
151           The SOAP::SOM object for the last successful deserialization, check
152           the return value of "validate()" or "success()" before using the
153           object.
154

BUGS

156       This module uses the SOAP interface for the W3C CSS validatom, which
157       still has a number of bugs, tracked via W3C's Bugzilla,
158       <http://www.w3.org/Bugs/Public/>.
159
160       Please report bugs in the W3C CSS Validator to www-validator-css@w3.org
161       or enter them directly in Bugzilla (see above). Please report bugs in
162       this module via RT, <http://rt.cpan.org/>.
163

NOTE

165       This module is not directly associated with the W3C. Please remember
166       that the CSS Validator is a shared resource so do not abuse it: you
167       should sleep between requests, and consider installing the Validator
168       locally, see http://jigsaw.w3.org/css-validator/DOWNLOAD.html
169       <http://jigsaw.w3.org/css-validator/DOWNLOAD.html>.
170

AUTHOR

172       Bjoern Hoehrmann <bjoern@hoehrmann.de>
173
174       This module is licensed under the same terms as Perl itself.
175
176
177
178perl v5.12.0                      2007-01-19WebService::Validator::CSS::W3C(3)
Impressum