--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+<!-- ********************************************************************\r
+ $Id: 0.1 postgis_mm.xml.xsl 2008-09-26 $\r
+ ********************************************************************\r
+ Copyright 2008, Regina Obe\r
+ License: BSD\r
+ Purpose: This is an xsl transform that generates index listing of aggregate functions and mm /sql compliant functions xml section from reference_new.xml to then\r
+ be processed by doc book\r
+ ******************************************************************** -->\r
+ <xsl:output method="xml" indent="yes" />\r
+ <xsl:template match='/chapter'>\r
+ \r
+ <title>PostGIS Aggregates Index</title>\r
+ <para>The functions given below are spatial aggregate functions provided with PostGIS that can\r
+ be used just like any other sql aggregate function such as sum, average.</para>\r
+ <chapter>\r
+ <sect1><title>PostGIS Aggregate Functions</title>\r
+ \r
+ <xsl:variable name="ap"><xsl:text>'</xsl:text></xsl:variable>\r
+<!-- Pull out the purpose section for each ref entry and strip whitespace and put in a variable to be tagged unto each function comment -->\r
+ <xsl:for-each select='sect1/refentry'>\r
+ <xsl:variable name='comment'>\r
+ <xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'
', ' '), '	', ' '))"/>\r
+ </xsl:variable>\r
+\r
+<!-- For each function prototype generate the DDL comment statement\r
+ If its input is a geometry set - we know it is an aggregate function rather than a regular function -->\r
+ <xsl:for-each select="refsynopsisdiv/funcsynopsis/funcprototype">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(paramdef/type,'geometry set')">\r
+ <p><xref linkend="{funcdef/function}" />(geometry <xsl:call-template name="listparams"><xsl:with-param name="func" select="." /></xsl:call-template>) - <xsl:value-of select='$comment' /></p>\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ </xsl:for-each>\r
+ </xsl:for-each>\r
+ </sect1>\r
+ \r
+ <sect1><title>PostGIS MM Compliant Functions</title>\r
+ <para>The functions given below are PostGIS functions that conform to the SQL/MM 3 standard</para>\r
+<!-- Pull out the purpose section for each ref entry and strip whitespace and put in a variable to be tagged unto each function comment -->\r
+ <xsl:for-each select='sect1/refentry'>\r
+ <xsl:variable name='comment'>\r
+ <xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'
', ' '), '	', ' '))"/>\r
+ </xsl:variable>\r
+ <xsl:variable name='refid'>\r
+ <xsl:value-of select='@id' />\r
+ </xsl:variable>\r
+\r
+<!-- For each function prototype generate the DDL comment statement\r
+ If its input is a geometry set - we know it is an aggregate function rather than a regular function -->\r
+ <xsl:for-each select="refsection">\r
+ <xsl:for-each select="para">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(.,'implements the SQL/MM')">\r
+ <p><xref linkend="{$refid}" /> - <xsl:value-of select='$comment' /></p>\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ </xsl:for-each>\r
+ </xsl:for-each>\r
+ </xsl:for-each>\r
+ </sect1>\r
+ </chapter>\r
+ </xsl:template>\r
+\r
+ <!--macro to pull out function parameter names so we can provide a pretty arg list prefix for each function -->\r
+ <xsl:template name="listparams">\r
+ <xsl:param name="func" />\r
+ <xsl:for-each select="$func">\r
+ <xsl:if test="count(paramdef/parameter) > 0">args: </xsl:if>\r
+ <xsl:for-each select="paramdef">\r
+ <xsl:choose>\r
+ <xsl:when test="count(parameter) > 0"> \r
+ <xsl:value-of select="parameter" />\r
+ </xsl:when>\r
+ </xsl:choose>\r
+ <xsl:if test="position()<last()"><xsl:text>, </xsl:text></xsl:if>\r
+ </xsl:for-each>\r
+ <xsl:if test="count(paramdef/parameter) > 0"> - </xsl:if>\r
+ </xsl:for-each> \r
+ </xsl:template>\r
+\r
+</xsl:stylesheet>\r