mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-30 13:37:17 +00:00
Introduce virXMLValidatorValidate
Split out the code for XML validation into a new function.
This commit is contained in:
parent
87ae612de9
commit
4702687cfb
@ -2567,6 +2567,7 @@ virXMLSaveFile;
|
|||||||
virXMLValidateAgainstSchema;
|
virXMLValidateAgainstSchema;
|
||||||
virXMLValidatorFree;
|
virXMLValidatorFree;
|
||||||
virXMLValidatorInit;
|
virXMLValidatorInit;
|
||||||
|
virXMLValidatorValidate;
|
||||||
virXPathBoolean;
|
virXPathBoolean;
|
||||||
virXPathInt;
|
virXPathInt;
|
||||||
virXPathLong;
|
virXPathLong;
|
||||||
|
@ -1156,15 +1156,11 @@ virXMLValidatorInit(const char *schemafile)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virXMLValidateAgainstSchema(const char *schemafile,
|
virXMLValidatorValidate(virXMLValidatorPtr validator,
|
||||||
xmlDocPtr doc)
|
xmlDocPtr doc)
|
||||||
{
|
{
|
||||||
virXMLValidatorPtr validator = NULL;
|
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!(validator = virXMLValidatorInit(schemafile)))
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (xmlRelaxNGValidateDoc(validator->rngValid, doc) != 0) {
|
if (xmlRelaxNGValidateDoc(validator->rngValid, doc) != 0) {
|
||||||
virReportError(VIR_ERR_XML_INVALID_SCHEMA,
|
virReportError(VIR_ERR_XML_INVALID_SCHEMA,
|
||||||
_("Unable to validate doc against %s\n%s"),
|
_("Unable to validate doc against %s\n%s"),
|
||||||
@ -1174,7 +1170,26 @@ virXMLValidateAgainstSchema(const char *schemafile,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
cleanup:
|
||||||
|
virBufferFreeAndReset(&validator->buf);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virXMLValidateAgainstSchema(const char *schemafile,
|
||||||
|
xmlDocPtr doc)
|
||||||
|
{
|
||||||
|
virXMLValidatorPtr validator = NULL;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
|
if (!(validator = virXMLValidatorInit(schemafile)))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (virXMLValidatorValidate(validator, doc) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virXMLValidatorFree(validator);
|
virXMLValidatorFree(validator);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -192,6 +192,10 @@ typedef virXMLValidator *virXMLValidatorPtr;
|
|||||||
virXMLValidatorPtr
|
virXMLValidatorPtr
|
||||||
virXMLValidatorInit(const char *schemafile);
|
virXMLValidatorInit(const char *schemafile);
|
||||||
|
|
||||||
|
int
|
||||||
|
virXMLValidatorValidate(virXMLValidatorPtr validator,
|
||||||
|
xmlDocPtr doc);
|
||||||
|
|
||||||
int
|
int
|
||||||
virXMLValidateAgainstSchema(const char *schemafile,
|
virXMLValidateAgainstSchema(const char *schemafile,
|
||||||
xmlDocPtr xml);
|
xmlDocPtr xml);
|
||||||
|
Loading…
Reference in New Issue
Block a user