mirror of https://gitee.com/openkylin/libvirt.git
lib: Replace xmlKeepBlanksDefault() with virXMLParseWithIndent()
Now that we have virXMLParseWithIndent() and virXMLParseStringCtxtWithIndent(), we can use them directly and drop calls to xmlKeepBlanksDefault(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
69958ba310
commit
1fdca3083b
|
@ -276,13 +276,11 @@ virDomainBackupDefParseString(const char *xmlStr,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
|
bool validate = !(flags & VIR_DOMAIN_BACKUP_PARSE_INTERNAL);
|
||||||
|
|
||||||
xml = virXMLParse(NULL, xmlStr, _("(domain_backup)"),
|
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_backup)"),
|
||||||
"domainbackup", &ctxt, "domainbackup.rng", validate);
|
"domainbackup", &ctxt, "domainbackup.rng",
|
||||||
|
validate);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -192,12 +192,10 @@ virDomainCheckpointDefParseString(const char *xmlStr,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
|
|
||||||
xml = virXMLParse(NULL, xmlStr, _("(domain_checkpoint)"),
|
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_checkpoint)"),
|
||||||
"domaincheckpoint", &ctxt, "domaincheckpoint.rng", true);
|
"domaincheckpoint", &ctxt,
|
||||||
|
"domaincheckpoint.rng", true);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -19503,13 +19503,10 @@ virDomainDefParse(const char *xmlStr,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
bool validate = flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA;
|
||||||
|
|
||||||
xml = virXMLParse(filename, xmlStr, _("(domain_definition)"),
|
xml = virXMLParseWithIndent(filename, xmlStr, _("(domain_definition)"),
|
||||||
"domain", &ctxt, "domain.rng", validate);
|
"domain", &ctxt, "domain.rng", validate);
|
||||||
|
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -19566,10 +19563,8 @@ virDomainObjParseFile(const char *filename,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
|
|
||||||
xml = virXMLParse(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
|
xml = virXMLParseWithIndent(filename, NULL, NULL, "domstatus", &ctxt, NULL, false);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1962,11 +1962,9 @@ virNetworkDefParse(const char *xmlStr,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
|
|
||||||
xml = virXMLParse(filename, xmlStr, _("(network_definition)"),
|
xml = virXMLParseWithIndent(filename, xmlStr, _("(network_definition)"),
|
||||||
"network", &ctxt, "network.rng", validate);
|
"network", &ctxt, "network.rng", validate);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -426,13 +426,11 @@ virDomainSnapshotDefParseString(const char *xmlStr,
|
||||||
{
|
{
|
||||||
g_autoptr(xmlXPathContext) ctxt = NULL;
|
g_autoptr(xmlXPathContext) ctxt = NULL;
|
||||||
g_autoptr(xmlDoc) xml = NULL;
|
g_autoptr(xmlDoc) xml = NULL;
|
||||||
int keepBlanksDefault = xmlKeepBlanksDefault(0);
|
|
||||||
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
bool validate = flags & VIR_DOMAIN_SNAPSHOT_PARSE_VALIDATE;
|
||||||
|
|
||||||
xml = virXMLParse(NULL, xmlStr, _("(domain_snapshot)"),
|
xml = virXMLParseWithIndent(NULL, xmlStr, _("(domain_snapshot)"),
|
||||||
"domainsnapshot", &ctxt, "domainsnapshot.rng", validate);
|
"domainsnapshot", &ctxt, "domainsnapshot.rng",
|
||||||
|
validate);
|
||||||
xmlKeepBlanksDefault(keepBlanksDefault);
|
|
||||||
|
|
||||||
if (!xml)
|
if (!xml)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -474,16 +474,13 @@ virshDumpXML(vshControl *ctl,
|
||||||
g_autofree xmlNodePtr *nodes = NULL;
|
g_autofree xmlNodePtr *nodes = NULL;
|
||||||
int nnodes = 0;
|
int nnodes = 0;
|
||||||
size_t i;
|
size_t i;
|
||||||
int oldblanks;
|
|
||||||
|
|
||||||
if (xpath == NULL) {
|
if (xpath == NULL) {
|
||||||
vshPrint(ctl, "%s", xml);
|
vshPrint(ctl, "%s", xml);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
oldblanks = xmlKeepBlanksDefault(0);
|
doc = virXMLParseStringCtxtWithIndent(xml, url, &ctxt);
|
||||||
doc = virXMLParseStringCtxt(xml, url, &ctxt);
|
|
||||||
xmlKeepBlanksDefault(oldblanks);
|
|
||||||
if (!doc)
|
if (!doc)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue