Install xslt_process on ProstgreSQL 8.4 Windows if it was not installed when PostgreSQL was
Is this possible? If so how?
I have looked at Libxslt which is what 开发者_如何学Cit uses but it seems to involve installing a bunch of binaries and still will not be available as PostgreSQL function...
UPDATE: I ended up having problems using xlst_process()
on large transformations which caused PostgreSQL to crash and ended up using FOP invoked by a plpythonu
function.
xslt_process is part of the contrib module xml2
http://www.postgresql.org/docs/current/static/xml2.html
So installing that module should give you xstl_process()
xslt_process() requires Libxml to be installed, available (by adding Windows PATH Environment variables) and the xslt_process() function to be created
Solution:
- Download and extract the zip: libxslt-1.1.26.win32.zip from ftp://ftp.zlatkovic.com/libxml/ to place on your dirve
- Add the location of xsltproc.exe to your Windows PATH environment varible such as: "C:\libxml\libxslt-1.1.26.win32\bin". You will know this is working when you can run it from the cmd line.
- libxml2.dll, libxslt.dll and iconv.dll which are also required by xsltproc.exe (they can downloaded using the above link but I found them to already be in my PostgreSQL\8.4\bin dir) and need to have their location added to the Windows PATH too, such as: "C:\PostgreSQL\8.4\bin"
- Run the SQL (which I copied from the bottom of "PostgreSQL\8.4\share\contrib\pgxml.sql"):
CREATE OR REPLACE FUNCTION xslt_process(text,text,text) RETURNS text AS '$libdir/pgxml' LANGUAGE C STRICT VOLATILE; -- the function checks for the correct argument count CREATE OR REPLACE FUNCTION xslt_process(text,text) RETURNS text AS '$libdir/pgxml' LANGUAGE C STRICT IMMUTABLE;
The Libxml windows binaries are helpfully maintained and provided by: http://www.zlatkovic.com/libxml.en.html
(NOTE: Windows User enviroment varibles do not require a restart but are only avaliable to the user, so my tip is add the varibles to System and User PATH's)
精彩评论