]> granicus.if.org Git - postgis/commitdiff
Put in author/license info (hmm this is a guess - couldn't find a good example in...
authorRegina Obe <lr@pcorp.us>
Fri, 26 Sep 2008 12:45:38 +0000 (12:45 +0000)
committerRegina Obe <lr@pcorp.us>
Fri, 26 Sep 2008 12:45:38 +0000 (12:45 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@3014 b70326c6-7e19-0410-871a-916f4a2858ee

doc/xsl/postgis_comments.sql.xsl

index b7a138a25d21675e14ee640e323e185c3342a017..3f4b12006b0f4622f2ad814eca88cc2a55c5ab19 100644 (file)
@@ -1,21 +1,31 @@
 <?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,'&#x0d;&#x0a;', ' '), '&#09;', ' '))"/>\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) &gt; 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()&lt;last()"><xsl:text>, </xsl:text></xsl:if></xsl:when>\r
@@ -24,6 +34,8 @@ COMMENT ON <xsl:choose><xsl:when test="contains(paramdef/type,'geometry set')">A
                </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
@@ -47,6 +59,7 @@ COMMENT ON <xsl:choose><xsl:when test="contains(paramdef/type,'geometry set')">A
          </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