Skip to contents

Bundles precomputed sitemapr outputs into a single validated sitemap_audit object with stable, named components. It performs no fetching, parsing, or validation of its own: it assembles shapes the package already produces (see read_sitemap(), validate_sitemap(), and sitemap_tree()) into one first-class result and validates their column contracts.

Usage

sitemap_audit(
  urls = NULL,
  findings = NULL,
  sources = NULL,
  problems = NULL,
  tree = NULL
)

Arguments

urls

A read_sitemap() tidy row tibble (optionally carrying the sources/problems attributes). Defaults to the empty row schema.

findings

A validate_sitemap() findings tibble. Defaults to the empty findings contract.

sources

The per-source fetch-metadata records. Defaults to the sources attribute of urls when present, otherwise the empty schema.

problems

The non-fatal parse problems companion table. Defaults to the problems attribute of urls when present, else the empty schema.

tree

A sitemap_tree() discovery/index structure. Defaults to the empty tree schema.

Value

A validated sitemap_audit object: a classed list with the components urls, findings, sources, problems, and tree. Access them with audit_urls(), audit_findings(), audit_sources(), audit_problems(), and audit_tree().

Details

Because a read_sitemap() result already carries its per-source metadata and non-fatal parse problems as the sources and problems attributes, those two components are pulled from urls when not passed explicitly, and then promoted to first-class components (the stored urls component is the plain tidy tibble, without those attributes). Any component left NULL defaults to its empty (zero-row) schema, so sitemap_audit() with no arguments is a valid empty audit and any subset of components yields a valid partial audit.

See also

read_sitemap(), validate_sitemap(), and sitemap_tree() for the component producers.

Examples

xml <- paste0(
  '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
  '<url><loc>https://example.com/</loc>',
  '<lastmod>2024-01-01</lastmod></url>',
  '<url><loc>https://example.com/about</loc></url>',
  '</urlset>'
)
path <- tempfile(fileext = ".xml")
writeLines(xml, path)

# Assemble precomputed read + validate results into one container.
audit <- sitemap_audit(
  urls = read_sitemap(path),
  findings = validate_sitemap(path, mode = "non-strict")
)
audit
#> <sitemap_audit>
#>   urls:     2
#>   findings: 0 (fatal 0, error 0, warning 0, info 0)
#>   sources:  1
#>   problems: 0
#>   tree:     0 nodes
summary(audit)
#> $n_urls
#> [1] 2
#> 
#> $findings
#>   fatal   error warning    info 
#>       0       0       0       0 
#> 
#> $n_sources
#> [1] 1
#> 
#> $n_problems
#> [1] 0
#> 
#> $n_tree
#> [1] 0
#> 

# An empty audit is valid (all components are zero-row schemas).
sitemap_audit()
#> <sitemap_audit>
#>   urls:     0
#>   findings: 0 (fatal 0, error 0, warning 0, info 0)
#>   sources:  0
#>   problems: 0
#>   tree:     0 nodes