xmlSchemaValidate            package:XML            R Documentation

_V_a_l_i_d_a_t_e _a_n _X_M_L _d_o_c_u_m_e_n_t _r_e_l_a_t_i_v_e _t_o _a_n _X_M_L _s_c_h_e_m_a

_D_e_s_c_r_i_p_t_i_o_n:

     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.

_U_s_a_g_e:

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

     schemaValidationErrorHandler()

_A_r_g_u_m_e_n_t_s:

  schema: an object of class 'xmlSchemaRef' which is usually the result
          of a call to 'xmlInternalTreeParse' with 'isSchema = TRUE',
          or 'xmlSchemaParse'.

     doc: an XML document which has already been parsed into a
          'XMLInternalDocument' or which is a file name or string which
          is coerced to an 'XMLInternalDocument-class' object

 options: an integer giving the options controlling the validation.  At
          present, this is either 0 or 1 and is essentially irrelevant
          to us. It may be of value in the future. 

errorHandler: a function or a list whose first element is a function
          which is then used as the collector for the warning and error
          messages reported during the validation. For each warning or
          error, this function is invoked and the class of the message
          is either 'XMLSchemaWarning' or 'XMLSchemaError'
          respectively. 

_V_a_l_u_e:

     Typically, a list with 3 elements: 

  status: 0 for validated, and non-zero for invalid

  errors: a character vector

warnings: a 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)

_R_e_f_e_r_e_n_c_e_s:

     libxml2 www.xmlsoft.org

_S_e_e _A_l_s_o:

     'xmlSchemaParse'

_E_x_a_m_p_l_e_s:

     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)

     xmlSchemaValidate(xsd, system.file("exampleData", "author2.xml",  package = "XML"))

