"Itagaki Takahiro" <itagaki.takahiro@oss.ntt.co.jp> writes:
> =# SELECT xmlelement(name a, xmlattributes('./qa?a=1&b=2' as href), 'Q&A');
> xmlelement
> --------------------------------------------
> <a href="./qa?a=1&b=2">Q&A</a>
> (1 row)
> '&' in xmlattributes seems to be encoded twice.
This was apparently broken by Peter's patch here:
http://archives.postgresql.org/pgsql-committers/2009-04/msg00124.php
map_sql_value_to_xml_value() performs mapping of & (and various other
special characters), and evidently xmlTextWriterWriteAttribute() does
it again.
I'm not sure about the most appropriate solution. The libxml2
documentation is so awful that it doesn't even tell you that
xmlTextWriterWriteAttribute does that, let alone suggest whether there
is another API function that doesn't. We might have to add a bool flag
to map_sql_value_to_xml_value() to enable or disable mapping of special
characters.
regards, tom lane