mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00: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 <sys/stat.h>
|
||||
|
||||
#include <libxml/xpathInternals.h>
|
||||
|
||||
#include "virerror.h"
|
||||
#include "virxml.h"
|
||||
#include "virbuffer.h"
|
||||
@ -1416,3 +1418,20 @@ virXMLNamespaceFormatNS(virBufferPtr buf,
|
||||
{
|
||||
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
|
||||
virXMLNamespaceFormatNS(virBufferPtr buf,
|
||||
virXMLNamespace const *ns);
|
||||
int
|
||||
virXMLNamespaceRegister(xmlXPathContextPtr ctxt,
|
||||
virXMLNamespace const *ns);
|
||||
|
Loading…
x
Reference in New Issue
Block a user