[TASK] Update ADOdb to 5.18
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / adodb / xsl / convert-0.2-0.1.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0"
3         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 >
5         <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="UTF-8"/>
6
7         <!-- Schema -->
8         <xsl:template match="/">
9                 <xsl:comment>
10 ADODB XMLSchema
11 http://adodb-xmlschema.sourceforge.net
12 </xsl:comment>
13
14                 <xsl:element name="schema">
15                         <xsl:attribute name="version">0.1</xsl:attribute>
16
17                         <xsl:apply-templates select="schema/table|schema/sql"/>
18                 </xsl:element>
19         </xsl:template>
20
21         <!-- Table -->
22         <xsl:template match="table">
23                 <xsl:variable name="table_name" select="@name"/>
24
25                 <xsl:element name="table">
26                         <xsl:attribute name="name"><xsl:value-of select="$table_name"/></xsl:attribute>
27
28                         <xsl:if test="string-length(@platform) > 0">
29                                 <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
30                         </xsl:if>
31
32                         <xsl:if test="string-length(@version) > 0">
33                                 <xsl:attribute name="version"><xsl:value-of select="@version"/></xsl:attribute>
34                         </xsl:if>
35
36                         <xsl:apply-templates select="descr[1]"/>
37
38                         <xsl:choose>
39                                 <xsl:when test="count(DROP) > 0">
40                                         <xsl:element name="DROP"/>
41                                 </xsl:when>
42                                 <xsl:otherwise>
43                                         <xsl:apply-templates select="field"/>
44                                 </xsl:otherwise>
45                         </xsl:choose>
46
47                         <xsl:apply-templates select="constraint"/>
48
49                 </xsl:element>
50
51                 <xsl:apply-templates select="index"/>
52         </xsl:template>
53
54         <!-- Field -->
55         <xsl:template match="field">
56                 <xsl:element name="field">
57                         <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
58                         <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
59
60                         <xsl:if test="string-length(@size) > 0">
61                                 <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
62                         </xsl:if>
63
64                         <xsl:choose>
65                                 <xsl:when test="count(PRIMARY) > 0">
66                                         <xsl:element name="PRIMARY"/>
67                                 </xsl:when>
68                                 <xsl:when test="count(KEY) > 0">
69                                         <xsl:element name="KEY"/>
70                                 </xsl:when>
71                                 <xsl:when test="count(NOTNULL) > 0">
72                                         <xsl:element name="NOTNULL"/>
73                                 </xsl:when>
74                         </xsl:choose>
75
76                         <xsl:choose>
77                                 <xsl:when test="count(AUTO) > 0">
78                                         <xsl:element name="AUTO"/>
79                                 </xsl:when>
80                                 <xsl:when test="count(AUTOINCREMENT) > 0">
81                                         <xsl:element name="AUTOINCREMENT"/>
82                                 </xsl:when>
83                         </xsl:choose>
84
85                         <xsl:choose>
86                                 <xsl:when test="count(DEFAULT) > 0">
87                                         <xsl:element name="DEFAULT">
88                                                 <xsl:attribute name="value">
89                                                         <xsl:value-of select="DEFAULT[1]/@value"/>
90                                                 </xsl:attribute>
91                                         </xsl:element>
92                                 </xsl:when>
93                                 <xsl:when test="count(DEFDATE) > 0">
94                                         <xsl:element name="DEFDATE">
95                                                 <xsl:attribute name="value">
96                                                         <xsl:value-of select="DEFDATE[1]/@value"/>
97                                                 </xsl:attribute>
98                                         </xsl:element>
99                                 </xsl:when>
100                                 <xsl:when test="count(DEFTIMESTAMP) > 0">
101                                         <xsl:element name="DEFDTIMESTAMP">
102                                                 <xsl:attribute name="value">
103                                                         <xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
104                                                 </xsl:attribute>
105                                         </xsl:element>
106                                 </xsl:when>
107                         </xsl:choose>
108
109                         <xsl:if test="count(NOQUOTE) > 0">
110                                 <xsl:element name="NOQUOTE"/>
111                         </xsl:if>
112
113                         <xsl:apply-templates select="constraint"/>
114                 </xsl:element>
115         </xsl:template>
116
117         <!-- Constraint -->
118         <xsl:template match="constraint">
119                 <xsl:element name="constraint">
120                         <xsl:value-of select="normalize-space(text())"/>
121                 </xsl:element>
122         </xsl:template>
123
124         <!-- Index -->
125         <xsl:template match="index">
126                 <xsl:element name="index">
127                         <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
128                         <xsl:attribute name="table"><xsl:value-of select="../@name"/></xsl:attribute>
129
130                         <xsl:apply-templates select="descr[1]"/>
131
132                         <xsl:if test="count(CLUSTERED) > 0">
133                                 <xsl:element name="CLUSTERED"/>
134                         </xsl:if>
135
136                         <xsl:if test="count(BITMAP) > 0">
137                                 <xsl:element name="BITMAP"/>
138                         </xsl:if>
139
140                         <xsl:if test="count(UNIQUE) > 0">
141                                 <xsl:element name="UNIQUE"/>
142                         </xsl:if>
143
144                         <xsl:if test="count(FULLTEXT) > 0">
145                                 <xsl:element name="FULLTEXT"/>
146                         </xsl:if>
147
148                         <xsl:if test="count(HASH) > 0">
149                                 <xsl:element name="HASH"/>
150                         </xsl:if>
151
152                         <xsl:choose>
153                                 <xsl:when test="count(DROP) > 0">
154                                         <xsl:element name="DROP"/>
155                                 </xsl:when>
156                                 <xsl:otherwise>
157                                         <xsl:apply-templates select="col"/>
158                                 </xsl:otherwise>
159                         </xsl:choose>
160                 </xsl:element>
161         </xsl:template>
162
163         <!-- Index Column -->
164         <xsl:template match="col">
165                 <xsl:element name="col">
166                         <xsl:value-of select="normalize-space(text())"/>
167                 </xsl:element>
168         </xsl:template>
169
170         <!-- SQL QuerySet -->
171         <xsl:template match="sql">
172                 <xsl:element name="sql">
173                         <xsl:if test="string-length(@platform) > 0">
174                                 <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
175                         </xsl:if>
176
177                         <xsl:if test="string-length(@key) > 0">
178                                 <xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
179                         </xsl:if>
180
181                         <xsl:if test="string-length(@prefixmethod) > 0">
182                                 <xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
183                         </xsl:if>
184
185                         <xsl:apply-templates select="descr[1]"/>
186                         <xsl:apply-templates select="query"/>
187                 </xsl:element>
188         </xsl:template>
189
190         <!-- Query -->
191         <xsl:template match="query">
192                 <xsl:element name="query">
193                         <xsl:if test="string-length(@platform) > 0">
194                                 <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
195                         </xsl:if>
196
197                         <xsl:value-of select="normalize-space(text())"/>
198                 </xsl:element>
199         </xsl:template>
200
201         <!-- Description -->
202         <xsl:template match="descr">
203                 <xsl:element name="descr">
204                         <xsl:value-of select="normalize-space(text())"/>
205                 </xsl:element>
206         </xsl:template>
207 </xsl:stylesheet>