<?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.2 postgis_comments.xsl 2008-09-26 $\r
+ ********************************************************************\r
+ Copyright 2008, Regina Obe\r
+ License: BSD\r
+ Purpose: This is an xsl transform that generates PostgreSQL COMMENT ON FUNCTION ddl\r
+ statements from postgis xml doc reference\r
+ ******************************************************************** -->\r
<xsl:output method="text" />\r
<xsl:template match='/chapter'>\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='plaincomment'>\r
- <xsl:value-of select="refnamediv/refpurpose" />\r
+ <xsl:value-of select="normalize-space(translate(translate(refnamediv/refpurpose,'
', ' '), '	', ' '))"/>\r
</xsl:variable>\r
- \r
- <xsl:variable name='comment'>\r
- <xsl:call-template name="globalReplace">\r
- <xsl:with-param name="outputString" select="$plaincomment"/>\r
- <xsl:with-param name="target" select="$ap"/>\r
- <xsl:with-param name="replacement" select="''"/>\r
- </xsl:call-template>\r
- </xsl:variable>\r
-\r
+<!-- Replace apostrophes with 2 apostrophes needed for escaping in SQL -->\r
+ <xsl:variable name='comment'>\r
+ <xsl:call-template name="globalReplace">\r
+ <xsl:with-param name="outputString" select="$plaincomment"/>\r
+ <xsl:with-param name="target" select="$ap"/>\r
+ <xsl:with-param name="replacement" select="''"/>\r
+ </xsl:call-template>\r
+ </xsl:variable>\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
COMMENT ON <xsl:choose><xsl:when test="contains(paramdef/type,'geometry set')">AGGREGATE</xsl:when><xsl:otherwise>FUNCTION</xsl:otherwise></xsl:choose><xsl:text> </xsl:text> <xsl:value-of select="funcdef/function" />(<xsl:for-each select="paramdef"><xsl:choose><xsl:when test="count(parameter) > 0"> \r
<xsl:choose><xsl:when test="contains(type,'geometry set')">geometry</xsl:when><xsl:otherwise><xsl:value-of select="type" /></xsl:otherwise></xsl:choose><xsl:if test="position()<last()"><xsl:text>, </xsl:text></xsl:if></xsl:when>\r
</xsl:for-each>\r
</xsl:template>\r
\r
+<!--General replace macro hack to make up for the fact xsl 1.0 does not have a built in one. \r
+ Not needed for xsl 2.0 lifted from http://www.xml.com/pub/a/2002/06/05/transforming.html -->\r
<xsl:template name="globalReplace">\r
<xsl:param name="outputString"/>\r
<xsl:param name="target"/>\r
</xsl:choose>\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