if (virXMLValidateAgainstSchema(schema, xml) < 0)
return NULL;
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virDomainCheckpointDefParse(ctxt, caps, xmlopt, parseOpaque, flags);
virDomainDefPtr def = NULL;
virDomainDefPtr ret = NULL;
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
goto cleanup;
}
- if (!(ctxt = xmlXPathNewContext(xml))) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
obj = virDomainObjParseXML(xml, ctxt, caps, xmlopt, flags);
return NULL;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virInterfaceDefParseXML(ctxt, VIR_INTERFACE_TYPE_LAST);
return NULL;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virNetworkDefParseXML(ctxt, xmlopt);
return NULL;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virNodeDeviceDefParseXML(ctxt, create, virt_type);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virNWFilterDefParseXML(ctxt);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
+
ctxt->node = root;
if (VIR_ALLOC(def) < 0)
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virDomainSnapshotDefParse(ctxt, caps, xmlopt, parseOpaque, current, flags);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virStoragePoolDefParseXML(ctxt);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virStorageVolDefParseXML(pool, ctxt, flags);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virNetworkPortDefParseXML(ctxt);
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
ctxt->node = root;
def = virNWFilterBindingDefParseXML(ctxt);
goto cleanup;
}
- ctxt = xmlXPathNewContext(doc);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(doc)))
goto cleanup;
- }
ctxt->node = root;
obj = virNWFilterBindingObjParseXML(doc, ctxt);
virXMLValidatorFree;
virXMLValidatorInit;
virXMLValidatorValidate;
+virXMLXPathContextNew;
virXPathBoolean;
virXPathContextNodeRestore;
virXPathInt;
if (!(doc = virXMLParseFile(filename)))
goto cleanup;
- if (!(ctxt = xmlXPathNewContext(doc))) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(doc)))
goto cleanup;
- }
ctxt->node = xmlDocGetRootElement(doc);
};
+xmlXPathContextPtr
+virXMLXPathContextNew(xmlDocPtr xml)
+{
+ xmlXPathContextPtr ctxt;
+
+ if (!(ctxt = xmlXPathNewContext(xml))) {
+ virReportOOMError();
+ return NULL;
+ }
+
+ return ctxt;
+}
+
+
/**
* virXPathString:
* @xpath: the XPath string to evaluate
}
if (ctxt) {
- *ctxt = xmlXPathNewContext(xml);
- if (!*ctxt) {
- virReportOOMError();
+ if (!(*ctxt = virXMLXPathContextNew(xml)))
goto error;
- }
+
(*ctxt)->node = xmlDocGetRootElement(xml);
}
#include "virbuffer.h"
#include "virautoclean.h"
+xmlXPathContextPtr virXMLXPathContextNew(xmlDocPtr xml)
+ ATTRIBUTE_RETURN_CHECK;
+
int virXPathBoolean(const char *xpath,
xmlXPathContextPtr ctxt);
char * virXPathString(const char *xpath,
_("Unable to parse the xml"));
goto cleanup;
}
- if (!(xPathContext = xmlXPathNewContext(xml))) {
- virReportOOMError();
+ if (!(xPathContext = virXMLXPathContextNew(xml)))
goto cleanup;
- }
+
if (xmlXPathRegisterNs(xPathContext,
BAD_CAST "vbox",
BAD_CAST "http://www.innotek.de/VirtualBox-settings") < 0) {
_("Unable to parse the xml"));
goto cleanup;
}
- if (!(xPathContext = xmlXPathNewContext(xml))) {
- virReportOOMError();
+
+ if (!(xPathContext = virXMLXPathContextNew(xml)))
goto cleanup;
- }
+
xPathContext->node = xmlDocGetRootElement(xml);
if ((nodeSize = virXPathNodeSet("/domainsnapshot/disks/disk",
xPathContext, &nodes)) < 0)
_("Unable to parse the xml"));
goto cleanup;
}
- if (!(xPathContext = xmlXPathNewContext(xml))) {
- virReportOOMError();
+
+ if (!(xPathContext = virXMLXPathContextNew(xml)))
goto cleanup;
- }
+
xPathContext->node = xmlDocGetRootElement(xml);
if ((nodeSize = virXPathNodeSet("/domainsnapshot/domain/devices/disk",
xPathContext,
goto cleanup;
}
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError();
+ if (!(ctxt = virXMLXPathContextNew(xml)))
goto cleanup;
- }
+
ctxt->node = root;
if ((n = virXPathNodeSet("//SavedStateItem", ctxt, &nodes)) < 0) {