Browse code

- added xsl template to generate the contents of version table for dbtext - dbschema for dbtext regenerated closes SER-386

Jan Janak authored on 25/06/2008 21:29:31
Showing 1 changed files
... ...
@@ -5,9 +5,11 @@
5 5
   
6 6
   <xsl:import href="common.xsl"/>
7 7
   <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
8
-  
9
-  <!-- Create the file for the table in dbtext subdirectory -->
10
-  <xsl:template match="table">
8
+
9
+  <!-- Special case for the version table, this table needs to be
10
+	   populated with versions of other tables
11
+	-->
12
+  <xsl:template match="table[@id='version']">
11 13
 	<xsl:variable name="name">
12 14
 	  <xsl:call-template name="get-name"/>
13 15
 	</xsl:variable>
... ...
@@ -19,8 +21,56 @@
19 21
 	   indent="no"
20 22
 	   omit-xml-declaration="yes">
21 23
 	  <xsl:apply-imports/>
24
+
25
+	  <xsl:variable name="version_table" select="."/>
26
+	  <xsl:for-each select="parent::database/table">
27
+		<xsl:if test="normalize-space(version/text())">
28
+		  <xsl:variable name="table" select="."/>
29
+		  <xsl:for-each select="$version_table/column">
30
+			<xsl:choose>
31
+			  <xsl:when test="@id='tn'">
32
+				<xsl:call-template name="escape">
33
+				  <xsl:with-param name="value">
34
+					<xsl:call-template name="get-name">
35
+					  <xsl:with-param name="select" select="$table"/>
36
+					</xsl:call-template>
37
+				  </xsl:with-param>
38
+				</xsl:call-template>
39
+			  </xsl:when>
40
+			  <xsl:when test="@id='tv'">
41
+				<xsl:call-template name="escape">
42
+				  <xsl:with-param name="value">
43
+					<xsl:value-of select="normalize-space($table/version/text())"/>
44
+				  </xsl:with-param>
45
+				</xsl:call-template>
46
+			  </xsl:when>
47
+			</xsl:choose>
48
+			<xsl:if test="position()!=last()">
49
+			  <xsl:text>:</xsl:text>	    
50
+			</xsl:if>
51
+		  </xsl:for-each>
52
+		  <xsl:text>&#x0A;</xsl:text>
53
+		</xsl:if>
54
+	  </xsl:for-each>
55
+
22 56
 	</xsl:document>
23 57
   </xsl:template>
58
+
59
+  <!-- Create the file for the table in dbtext subdirectory -->
60
+  <xsl:template match="table">
61
+	<xsl:variable name="name">
62
+	  <xsl:call-template name="get-name"/>
63
+	</xsl:variable>
64
+
65
+	<xsl:variable name="path" select="concat($dir, concat('/', concat($prefix, $name)))"/>
66
+	<xsl:document 
67
+	   href="{$path}"
68
+	   method="text"
69
+	   indent="no"
70
+	   omit-xml-declaration="yes">
71
+	  <xsl:apply-imports/>
72
+	</xsl:document>
73
+  </xsl:template> <!-- table -->
24 74
   
25 75
   <!-- Create column definitions -->
26 76
   <xsl:template match="column">
... ...
@@ -65,7 +115,7 @@
65 115
 	<xsl:if test="position()=last()">
66 116
 	  <xsl:text>&#x0A;</xsl:text>
67 117
 	</xsl:if>
68
-  </xsl:template>
118
+  </xsl:template> <!-- column -->
69 119
   
70 120
   <!-- Escape all : occurrences -->
71 121
   <xsl:template name="escape">
... ...
@@ -81,7 +131,7 @@
81 131
 		<xsl:value-of select="$value"/>
82 132
 	  </xsl:otherwise>
83 133
 	</xsl:choose>
84
-  </xsl:template>
134
+  </xsl:template> <!-- escape -->
85 135
   
86 136
   <!-- Process initial data -->
87 137
   <xsl:template match="row">
... ...
@@ -138,8 +188,8 @@
138 188
 	
139 189
 	<xsl:apply-imports/>
140 190
 	<xsl:text>&#x0A;</xsl:text>
141
-  </xsl:template>
142
-  
191
+  </xsl:template> <!-- row -->
192
+
143 193
   <!-- Make sure all values reference existing columns -->
144 194
   <xsl:template match="value">
145 195
 	<xsl:variable name="column">
... ...
@@ -147,5 +197,6 @@
147 197
 		<xsl:with-param name="id" select="@col"/>
148 198
 	  </xsl:call-template>
149 199
 	</xsl:variable>
150
-  </xsl:template>
200
+  </xsl:template> <!-- value -->
201
+
151 202
 </xsl:stylesheet>