A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.
To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).
Validator.nu JSON Output: Difference between revisions
Line 98: | Line 98: | ||
===The <code>"result"</code> ''object''=== | ===The <code>"result"</code> ''object''=== | ||
A <code>"result"</code> ''object'' has one mandatory key, <code>"type"</code>, and one optional key, <code>"message"</code>. | |||
====The <code>"type"</code> ''string''==== | |||
====The <code>"message"</code> ''string''==== | |||
===The <code>"source"</code> ''object''=== | ===The <code>"source"</code> ''object''=== |
Revision as of 10:38, 12 September 2007
This is a draft of a Web service response format for Validator.nu for clients that prefer JSON over XML.
Italicized words, such as object, refer to JSON data types. “The "foo"
datatype” refers to an object of type datatype that is the value associated with the key "foo"
in the parent object.
Root Object
The root object is a JSON object. It has two mandatory keys, "messages"
and "result"
, and three optional keys, "url"
, "source"
and "parseTree"
.
The values for these keys are described below.
The "messages"
array
The this array is an ordered collection of zero or more message objects.
Message objects
A message object has one mandatory key, "type"
, and seven optional keys, "subtype"
, "message"
, "extract"
, "offset"
, "url"
, "line"
and "column"
.
The "type"
string
The "type"
string denotes the general class of the message. The permissible values are "info"
, "error"
and "non-document-error"
.
"info"
means an informational message or warning that does not affect the validity of
the document being checked. "error"
signifies
a problem that causes the validation/checking to fail. "non-document-error"
signifies an error that causes the checking to end in an indeterminate state because
the document being validated could not be examined to the end. Examples of such errors include broken schemas, bugs in the validator and IO errors. (Note that when a schema has parse errors, they are first reported as error
s and then a catch-all non-document-error
is also emitted.)
The "subtype"
string
The permissible value with "type":"info"
is "warning"
, which means that the message seeks to warn about the user of a formally conforming but in some way questionable issue. Otherwise, the message is taken to generally informative.
The permissible value with "type":"error"
is "fatal"
, which means that the error is an XML well-formedness error or, in the case of HTML, a condition that the implementor has opted to treat analogously to XML well-formedness errors (e.g. due to usability or performance considerations). Further errors are suppressed after a fatal error. In the absence of the "subtype"
key, a "type":"error"
message means a spec violation in general.
Permissible values with "type":"non-document-error"
are: "io"
(signifies an
input/output error), "schema"
(indicates that
initializing a schema-based validator failed) and "internal"
(indicates that the validator/checker found an error bug in itself,
ran out of memory, etc., but was still able to emit a message). In the absence of the "subtype"
key, a "type":"non-document-error"
message means a problem external to the document in general.
The "message"
string
The "message"
string represents a paragraph of text (suitable for rendering to the user as plain text without further processing) that is the message stated succinctly in natural language.
The "extract"
string
The "extract"
string represents an extract of the document source from around the point in source designated for the message by the "line"
and "column"
numbers.
The "offset"
number
The "offset"
number is an UTF-16 code unit index into the "extract"
string. The index identifies the same UTF-16 code unit in the extract that the "line"
and "column"
numbers identify in the full source. The first code unit has the index 0
.
The "url"
string
The "url"
string, if present, must contain the URI
(not IRI) of the resource with which the message is associated
or the literal string “data:…
” (the last character
is U+2026) to signify that the message is associated with a data URI
resource but the exact URI has been omitted. (If a client application
wishes to show IRIs to human users, it is up to the client
application to convert the URI into an IRI.)
If the "url"
string is absent on the message element but present on the root element, the message is considered to be associated with the resource designated by the attribute on the root element.
The "line"
number
The "line"
number, if present, must contain a positive
integer (not zero). This number means the approximate source text
line number associated with the message. The first line is 1
.
The "column"
number
The "column"
number, if present, must contain a
positive integer (not zero). This number means the approximate source
column number associated with the message on the line indicated by
the "line"
number. The first character on a line is in
column 1.
The source lines and columns are approximate. For example, if a message is related to an attribute, the line and column may point to the first character if the start tag, the character after the start tag or to the attribute inside the tag depending on implementation. If a message is related to character data, the line and column may be inaccurate within a run of text e.g. due to buffering. Furthermore, implementation may count column numbers in terms of UTF-16 code units instead of characters.
The "url"
string
The "url"
string, if present, must containt the URI
(not IRI) of the document being checked
or the literal string “data:…
” (the last character
is U+2026) to signify that the message is associated with a data URI
resource but the exact URI has been omitted. (If a client application
wishes to show IRIs to human users, it is up to the client
application to convert the URI into an IRI.)
The "result"
object
A "result"
object has one mandatory key, "type"
, and one optional key, "message"
.
The "type"
string
The "message"
string
The "source"
object
The "parseTree"
object
Example
{ "url": "http://example.org/", "messages": [ { "type" : "info", "subtype": "warning", "line" : 20, "column" : 15, "url" : "http://example.com/", "message": "Trailing slash for void element", "extract": "<br/>", "offset" : 3 }, { "type" : "error", "subtype": "fatal", "line" : 42, "column" : 17, "url" : "http://example.com/", "message": "Missing end tag for the <code>foo</code> element" } ], "result": { "type" : "failure", "source": { "type" : "text/html", "encoding": "UTF-8" }, "parseTree": { ... } } };