mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
util: xml: introduce virXMLNamespaceRegister
A wrapper around xmlXPathRegisterNs that will save us from having to include xpathInternals.h everywhere we want to use a custom namespace and open-coding the strings already contained in virXMLNamespace. Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
56ecb33102
commit
37a11c3726
@ -24,6 +24,8 @@
|
|||||||
#include <math.h> /* for isnan() */
|
#include <math.h> /* for isnan() */
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <libxml/xpathInternals.h>
|
||||||
|
|
||||||
#include "virerror.h"
|
#include "virerror.h"
|
||||||
#include "virxml.h"
|
#include "virxml.h"
|
||||||
#include "virbuffer.h"
|
#include "virbuffer.h"
|
||||||
@ -1416,3 +1418,20 @@ virXMLNamespaceFormatNS(virBufferPtr buf,
|
|||||||
{
|
{
|
||||||
virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
|
virBufferAsprintf(buf, " xmlns:%s='%s'", ns->prefix, ns->href());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
|
||||||
|
virXMLNamespace const *ns)
|
||||||
|
{
|
||||||
|
if (xmlXPathRegisterNs(ctxt,
|
||||||
|
BAD_CAST ns->prefix,
|
||||||
|
BAD_CAST ns->href()) < 0) {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Failed to register xml namespace '%s'"),
|
||||||
|
ns->href());
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -265,3 +265,6 @@ typedef virXMLNamespace *virXMLNamespacePtr;
|
|||||||
void
|
void
|
||||||
virXMLNamespaceFormatNS(virBufferPtr buf,
|
virXMLNamespaceFormatNS(virBufferPtr buf,
|
||||||
virXMLNamespace const *ns);
|
virXMLNamespace const *ns);
|
||||||
|
int
|
||||||
|
virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
|
||||||
|
virXMLNamespace const *ns);
|
||||||
|
Loading…
Reference in New Issue
Block a user