From d6a68e964022c5fe6c2641919882a0a2312a7e11 Mon Sep 17 00:00:00 2001 From: Kathy Lussier Date: Fri, 10 Mar 2017 22:53:18 -0500 Subject: [PATCH] LP#1442276: Upgrade script for Encoding UTF8 output Signed-off-by: Kathy Lussier Signed-off-by: Dan Scott --- .../xxxx.function.oils_xslt_process_utf8_fix | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix new file mode 100644 index 0000000000..9557c4fa8d --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.function.oils_xslt_process_utf8_fix @@ -0,0 +1,43 @@ +BEGIN; + +--SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); + +CREATE OR REPLACE FUNCTION evergreen.oils_xslt_process(TEXT, TEXT) RETURNS TEXT AS $func$ + use strict; + + use XML::LibXSLT; + use XML::LibXML; + + my $doc = shift; + my $xslt = shift; + + # The following approach uses the older XML::LibXML 1.69 / XML::LibXSLT 1.68 + # methods of parsing XML documents and stylesheets, in the hopes of broader + # compatibility with distributions + my $parser = $_SHARED{'_xslt_process'}{parsers}{xml} || XML::LibXML->new(); + + # Cache the XML parser, if we do not already have one + $_SHARED{'_xslt_process'}{parsers}{xml} = $parser + unless ($_SHARED{'_xslt_process'}{parsers}{xml}); + + my $xslt_parser = $_SHARED{'_xslt_process'}{parsers}{xslt} || XML::LibXSLT->new(); + + # Cache the XSLT processor, if we do not already have one + $_SHARED{'_xslt_process'}{parsers}{xslt} = $xslt_parser + unless ($_SHARED{'_xslt_process'}{parsers}{xslt}); + + my $stylesheet = $_SHARED{'_xslt_process'}{stylesheets}{$xslt} || + $xslt_parser->parse_stylesheet( $parser->parse_string($xslt) ); + + $_SHARED{'_xslt_process'}{stylesheets}{$xslt} = $stylesheet + unless ($_SHARED{'_xslt_process'}{stylesheets}{$xslt}); + + return $stylesheet->output_as_chars( + $stylesheet->transform( + $parser->parse_string($doc) + ) + ); + +$func$ LANGUAGE 'plperlu' STRICT IMMUTABLE; + +COMMIT; -- 2.43.2