w3c_markup_validate_db: Collections of W3C Markup Validation Results

View source: R/w3c.R

w3c_markup_validate_dbR Documentation

Collections of W3C Markup Validation Results

Description

Create and manipulate collections of W3C markup validation results.

Usage

w3c_markup_validate_db(x, names = NULL)

w3c_markup_validate_files(files, baseurl = w3c_markup_validate_baseurl(),
                          opts = list())                    
w3c_markup_validate_uris(uris, baseurl = w3c_markup_validate_baseurl(),
                         opts = list())

Arguments

x

a list of w3c_markup_validate results.

names

a character vector of names for the elements in x, or NULL (default), indicating to use the names of x or to auto-generate names if these are NULL.

files

a character vector giving the names of files to validate.

uris

a character vector giving URIs to validate.

baseurl

a character string giving the URL of the W3C Markup Validation service to employ.

opts

see w3c_markup_validate.

Details

w3c_markup_validate_db() creates a db (data base) of w3c_markup_validate results as a list of these results with class "w3c_markup_validate_db". This class has methods for print and c for compactly summarizing and combining results, an inspect method for inspecting details, and an as.data.frame method for collapsing the errors and warnings into a “flat” data frame useful for further analyses.

w3c_markup_validate_files() and w3c_markup_validate_uris() validate the markup in the given files or URIs, with results combined into such results db objects. For files or URIs for which validation failed (which can happen for example when these contain characters invalid in SGML), the corresponding error condition objects are gathered into the "failures" attribute of the results db returned.

See Also

w3c_markup_validate_baseurl for getting and setting the URL of the validation service.

Examples

## Test files provided with this package:
dir <- system.file("examples", package = "W3CMarkupValidator")
files <- Sys.glob(file.path(dir, "*.html"))
if(!grepl("^http://validator.w3.org",
          w3c_markup_validate_baseurl())) {
    ## Validate.
    results <- w3c_markup_validate_files(files)
    results
    ## In case of failures, inspect the error messages:
    lapply(attr(results, "failures"), conditionMessage)
    ## Inspect validation results:
    inspect(results)
    inspect(results, full = TRUE)
    ## Turn results into a data frame:
    df <- as.data.frame(results)
    ## Tabulate error messages:
    table(substring(df$message, 1L, 60L))
    ## Inspect a particular set of error messages:
    df[df$message == "element \"font\" undefined", ]
    ## (Note that explanations are in HTML ...)
    ## Conveniently view the full records (modulo HTML markup):
    write.dcf(df)
}

W3CMarkupValidator documentation built on Feb. 16, 2023, 7:09 p.m.