Browse Source

doc/stylesheets: xsl template to quote mysql table and column names

Daniel-Constantin Mierla 10 years ago
parent
commit
15516b1e4a
2 changed files with 17 additions and 0 deletions
  1. 11 0
      doc/stylesheets/dbschema_k/xsl/common.xsl
  2. 6 0
      doc/stylesheets/dbschema_k/xsl/sql.xsl

+ 11 - 0
doc/stylesheets/dbschema_k/xsl/common.xsl

@@ -41,6 +41,17 @@
     <xsl:template match="text()|@*"/>
     <xsl:template match="text()|@*" mode="drop"/>
 
+    <xsl:template name="quotechar">
+	<xsl:choose>
+	    <xsl:when test="$db='mysql'">
+			<xsl:text>`</xsl:text>
+	    </xsl:when>
+	    <xsl:otherwise>
+			<xsl:text></xsl:text>
+		</xsl:otherwise>
+	</xsl:choose>
+    </xsl:template>
+
     <!-- Return the name of the context element, first look for a database
          specific name, use the common name if no database-specific name
          is found.

+ 6 - 0
doc/stylesheets/dbschema_k/xsl/sql.xsl

@@ -55,7 +55,9 @@
 	<xsl:apply-templates select="version"/>
 
 	<xsl:text>CREATE TABLE </xsl:text>
+	<xsl:call-template name="quotechar"/>
 	<xsl:value-of select="$table.name"/>
+	<xsl:call-template name="quotechar"/>
 	<xsl:text> (&#x0A;</xsl:text>
 
 	<!-- Process all columns -->
@@ -173,7 +175,9 @@
 
     <xsl:template match="column">
 	<xsl:text>    </xsl:text>
+	<xsl:call-template name="quotechar"/>
 	<xsl:call-template name="get-name"/>
+	<xsl:call-template name="quotechar"/>
 	<xsl:text> </xsl:text>
 
 	<xsl:call-template name="column.type"/>
@@ -245,9 +249,11 @@
 <!-- ################ COLREF ################  -->
 
     <xsl:template match="colref">
+	<xsl:call-template name="quotechar"/>
 	<xsl:call-template name="get-column-name">
 	    <xsl:with-param name="select" select="@linkend"/>
 	</xsl:call-template>
+	<xsl:call-template name="quotechar"/>
 	<xsl:if test="not(position()=last())">
 	    <xsl:text>, </xsl:text>
 	</xsl:if>