Learn R Programming

XML (version 3.1-1)

xmlSchemaValidate: Validate an XML document relative to an XML schema

Description

This function validates an XML document relative to an XML schema to ensure that it has the correct structure, i.e. valid sub-nodes, attributes, etc.

The xmlSchemaValidationErrorHandler is a function that returns a list of functions which can be used to cumulate or collect the errors and warnings from the schema validation operation.

Usage

xmlSchemaValidate(schema, doc, 
                                 errorHandler = xmlErrorFun(),
                                  options = 0L)

schemaValidationErrorHandler()

Arguments

Value

  • Typically, a list with 3 elements:
  • status0 for validated, and non-zero for invalid
  • errorsa character vector
  • warningsa character vector
  • If an empty error handler is provided (i.e. NULL) just an integer indicating the status of the validation is returned. 0 indicates everything was okay; a non-zero value indicates a validation error. (-1 indicates an internal error in libxml2)

concept

  • validation
  • XML
  • schema

References

libxml2 www.xmlsoft.org

See Also

xmlSchemaParse

Examples

Run this code
if(FALSE) {
  xsd = xmlTreeParse(system.file("exampleData", "author.xsd", package = "XML"), isSchema =TRUE, useInternal = TRUE)
  doc = xmlInternalTreeParse(system.file("exampleData", "author.xml",  package = "XML"))
  xmlSchemaValidate(xsd, doc)
}

Run the code above in your browser using DataLab