From ec8b943faef89235c0806db983864398acba5b2c Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Fri, 16 Mar 2012 21:49:45 -0400 Subject: [PATCH] Add an XML pretty printer database function Andrew Dunstan was kind enough to share an XML pretty printer function for PostgreSQL, and it sure is handy when you're debugging things like in-database unapi and MARCXML. Note that it expects honest-to-goodness XML data type input, so for biblio.record_entry.marc columns you'll need to cast it from TEXT. Signed-off-by: Dan Scott Signed-off-by: Michael Peters --- Open-ILS/src/sql/Pg/000.functions.general.sql | 21 +++++++++++++++++++++ .../Pg/upgrade/XXXX.function.xml_pretty_print.sql | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.function.xml_pretty_print.sql diff --git a/Open-ILS/src/sql/Pg/000.functions.general.sql b/Open-ILS/src/sql/Pg/000.functions.general.sql index 6a46d1b40c..ffbc6299d0 100644 --- a/Open-ILS/src/sql/Pg/000.functions.general.sql +++ b/Open-ILS/src/sql/Pg/000.functions.general.sql @@ -36,4 +36,25 @@ $$ LANGUAGE PLPERLU STRICT IMMUTABLE; -- Provide a named type for patching functions CREATE TYPE evergreen.patch AS (patch TEXT); +CREATE OR REPLACE FUNCTION evergreen.xml_pretty_print(input XML) + RETURNS XML + LANGUAGE SQL AS +$func$ +SELECT xslt_process($1::text, +$$ + + + + + + + + +$$::text)::XML +$func$; + +COMMENT ON FUNCTION evergreen.xml_pretty_print(input XML) IS +'Simple pretty printer for XML, as written by Andrew Dunstan at http://goo.gl/zBHIk'; + COMMIT; diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.function.xml_pretty_print.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.xml_pretty_print.sql new file mode 100644 index 0000000000..09928217a4 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.function.xml_pretty_print.sql @@ -0,0 +1,21 @@ +CREATE OR REPLACE FUNCTION evergreen.xml_pretty_print(input XML) + RETURNS XML + LANGUAGE SQL AS +$func$ +SELECT xslt_process($1::text, +$$ + + + + + + + + +$$::text)::XML +$func$; + +COMMENT ON FUNCTION evergreen.xml_pretty_print(input XML) IS +'Simple pretty printer for XML, as written by Andrew Dunstan at http://goo.gl/zBHIk'; + -- 2.11.0