提交 37a11c37 编写于 作者: J Ján Tomko

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: NJán Tomko <jtomko@redhat.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
上级 56ecb331
......@@ -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);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册