plxslt
XSLT procedural language for PostgreSQL
Repository
petere/plxslt
https://github.com/petere/plxslt
Source
plxslt-0.20140221.tar.gz
plxslt-0.20140221.tar.gz
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
plxslt | 0.20140221 | LANG | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 3110 | plxslt | No | Yes | No | Yes | No | Yes | - |
| Related | plpgsql pgml plpython3u pg_tle plv8 pljava plperl pllua |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PGDG | 0.20140221 | 1817161514 | plxslt | - |
| RPM | PGDG | 0.20140221 | 1817161514 | plxslt_$v | - |
| DEB | PIGSTY | 0.20140221 | 1817161514 | postgresql-$v-plxslt | - |
Build
You can build the DEB packages for plxslt using pig build:
pig build pkg plxslt # build DEB packages
Install
You can install plxslt directly. First, make sure the PGDG repository is added and enabled:
pig repo add pgdg -u # Add PGDG repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install plxslt; # Install for current active PG version
pig ext install -y plxslt -v 18 # PG 18
pig ext install -y plxslt -v 17 # PG 17
pig ext install -y plxslt -v 16 # PG 16
pig ext install -y plxslt -v 15 # PG 15
pig ext install -y plxslt -v 14 # PG 14
dnf install -y plxslt_18 # PG 18
dnf install -y plxslt_17 # PG 17
dnf install -y plxslt_16 # PG 16
dnf install -y plxslt_15 # PG 15
dnf install -y plxslt_14 # PG 14
apt install -y postgresql-18-plxslt # PG 18
apt install -y postgresql-17-plxslt # PG 17
apt install -y postgresql-16-plxslt # PG 16
apt install -y postgresql-15-plxslt # PG 15
apt install -y postgresql-14-plxslt # PG 14
Create Extension:
CREATE EXTENSION plxslt;
Usage
plxslt enables writing PostgreSQL functions as XSLT stylesheets for transforming XML data.
CREATE EXTENSION plxslt;
Create XSLT Functions
The function body is an XSLT stylesheet. The first parameter must be of type xml and receives the input document:
CREATE FUNCTION extract_title(xml) RETURNS xml AS $$
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:value-of select="//title"/>
</xsl:template>
</xsl:stylesheet>
$$ LANGUAGE xslt;
SELECT extract_title('<doc><title>Hello World</title></doc>'::xml);
Return Types
The return type must match the stylesheet’s output method:
| Output Method | Return Type |
|---|---|
xml | xml |
text | text or varchar |
html | text or varchar |
Passing Parameters
Additional function parameters beyond the first xml parameter are passed as XSL stylesheet parameters:
CREATE FUNCTION transform_with_param(xml, text) RETURNS xml AS $$
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="arg2"/>
<xsl:template match="/">
<result>
<xsl:value-of select="$arg2"/>
</result>
</xsl:template>
</xsl:stylesheet>
$$ LANGUAGE xslt;
Limitations
- First parameter must be
xmltype - Triggers are not supported
- Only XSLT 1.0 transformations are supported (via libxslt)
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.