Fix xpath() to return namespace definitions

From: Ali Akbar <the(dot)apaan(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fix xpath() to return namespace definitions
Date: 2014-05-30 09:04:33
Message-ID: CACQjQLo18s5Lpx9ngh5Qd1mhB4OukC12MzcjFwy0LQr2kw2DoQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

While developing some XML processing queries, i stumbled on an old bug
mentioned in http://wiki.postgresql.org/wiki/Todo#XML: Fix Nested or
repeated xpath() that apparently mess up namespaces.

Source of the bug is that libxml2's xmlNodeDump won't output XML namespace
definitions that declared in the node's parents. As per
https://bug639036.bugzilla-attachments.gnome.org/attachment.cgi?id=177858,
the behavior is intentional.

This patch uses function xmlCopyNode that copies a node, including its
namespace definitions as required (without unused namespace in the node or
its children). When the copy dumped, the resulting XML is complete with its
namespaces. Calling xmlCopyNode will need additional memory to execute, but
reimplementing its routine to handle namespace definition will introduce
much complexity to the code.

Note: This is my very first postgresql patch.

--
Ali Akbar

Attachment Content-Type Size
xpath-ns-fix.patch text/x-patch 4.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2014-05-30 10:18:45 Re: pg_class.relpages/allvisible probably shouldn't be a int4
Previous Message Heikki Linnakangas 2014-05-30 07:33:35 Re: Fwd: Typo fixes in Solution.pm, part of MSVC scripts