[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 18/21] util: xml: introduce virXMLNamespaceRegister



On Wed, Aug 21, 2019 at 01:15:40 +0200, Ján Tomko wrote:
> 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>
> ---
>  src/util/virxml.c | 20 ++++++++++++++++++++
>  src/util/virxml.h |  3 +++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/src/util/virxml.c b/src/util/virxml.c
> index 11b6031b09..84b824f432 100644
> --- a/src/util/virxml.c
> +++ b/src/util/virxml.c
> @@ -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"
> @@ -1409,9 +1411,27 @@ virXPathContextNodeRestore(virXPathContextNodeSavePtr save)
>      save->ctxt->node = save->node;
>  }
>  
> +

Oh I see, squash this into the patch which introduced
virXMLNamespaceFormatNS, please.

>  void
>  virXMLNamespaceFormatNS(virBufferPtr buf,
>                          virXMLNamespace const *ns)
>  {
>      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;
> +}

Reviewed-by: Jiri Denemark <jdenemar redhat com>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]