1<?xml version='1.0'?>
2<!--
3 * $Id: $
4 *
5 * XSL converter script for db_redis
6 *
7 * Copyright (C) 2001-2007 FhG Fokus
8 *
9 * This file is part of Kamailio, a free SIP server.
10 *
11 * Kamailio is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version
15 *
16 * Kamailio is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
24 *
25 */
26-->
27
28
29<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
30                version='1.0'
31                xmlns:xi="http://www.w3.org/2001/XInclude">
32
33    <xsl:import href="common.xsl"/>
34    <xsl:output method="text" indent="no" omit-xml-declaration="yes"/>
35
36    <!-- Create the file for the table in dbtext subdirectory -->
37    <xsl:template match="table">
38	<xsl:variable name="name">
39	    <xsl:call-template name="get-name"/>
40	</xsl:variable>
41
42	<xsl:variable name="path" select="concat($dir, concat('/', concat($prefix, $name)))"/>
43	<xsl:document href="{$path}" method="text" indent="no" omit-xml-declaration="yes">
44		<xsl:apply-imports/>
45		<!-- Insert version data -->
46		 <xsl:apply-templates select="version"/>
47		<!-- this is not exactly what we want for dbtext, as the version data gets
48		     appended to the actual table file, and no to the 'version' table.
49		     But its not possible (at least with XSL 1.0, AFAIK) to append data to a
50		     file. So it's much more easier to do this in the Makefile -->
51	</xsl:document>
52    </xsl:template>
53
54    <!-- version data template -->
55    <xsl:template match="version">
56	<xsl:value-of select="text()"/>
57	<xsl:text>&#x0A;</xsl:text>
58    </xsl:template>
59
60    <!-- Create column definitions -->
61    <xsl:template match="column">
62	<xsl:variable name="type">
63	    <xsl:call-template name="get-type"/>
64	</xsl:variable>
65
66	<xsl:variable name="null">
67	    <xsl:call-template name="get-null"/>
68	</xsl:variable>
69
70	<xsl:call-template name="get-name"/>
71	<xsl:text>/</xsl:text>
72	<xsl:choose>
73	    <xsl:when test="type[@db=$db]">
74		<xsl:value-of select="normalize-space(type[@db=$db])"/>
75	    </xsl:when>
76	    <xsl:when test="$type='char' or
77						$type='short' or
78						$type='int' or
79						$type='long' or
80						$type='datetime'">
81		<xsl:text>int</xsl:text>
82	    </xsl:when>
83	    <xsl:when test="$type='float' or
84						$type='double'">
85		<xsl:text>double</xsl:text>
86	    </xsl:when>
87	    <xsl:when test="$type='string' or
88						$type='text' or
89						$type='binary' or
90                        $type='largetext' or
91						$type='largebinary'">
92		<xsl:text>string</xsl:text>
93	    </xsl:when>
94	    <xsl:otherwise>
95		<xsl:call-template name="type-error"/>
96	    </xsl:otherwise>
97	</xsl:choose>
98
99    <!--
100	<xsl:if test="$null=1">
101	    <xsl:text>&amp;null</xsl:text>
102    </xsl:if>
103    -->
104	<xsl:text>,</xsl:text>
105	<xsl:if test="position()=last()">
106	    <xsl:text>&#x0A;</xsl:text>
107	</xsl:if>
108    </xsl:template>
109
110    <!-- Escape all : occurrences -->
111    <xsl:template name="escape">
112	<xsl:param name="value"/>
113	<xsl:choose>
114	    <xsl:when test="contains($value, ':')">
115		<xsl:value-of select="concat(substring-before($value, ':'), '\:')"/>
116		<xsl:call-template name="escape">
117		    <xsl:with-param name="value" select="substring-after($value, ':')"/>
118		</xsl:call-template>
119	    </xsl:when>
120	    <xsl:otherwise>
121		<xsl:value-of select="$value"/>
122	    </xsl:otherwise>
123	</xsl:choose>
124    </xsl:template>
125
126</xsl:stylesheet>
127