[TASK] Update ADOdb to 5.18
[Packages/TYPO3.CMS.git] / typo3 / sysext / adodb / adodb / xsl / convert-0.1-0.2.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.2</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:apply-templates select="../index[@table=$table_name]"/>
50                 </xsl:element>
51         </xsl:template>
52
53         <!-- Field -->
54         <xsl:template match="field">
55                 <xsl:element name="field">
56                         <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
57                         <xsl:attribute name="type"><xsl:value-of select="@type"/></xsl:attribute>
58
59                         <xsl:if test="string-length(@size) > 0">
60                                 <xsl:attribute name="size"><xsl:value-of select="@size"/></xsl:attribute>
61                         </xsl:if>
62
63                         <xsl:choose>
64                                 <xsl:when test="count(PRIMARY) > 0">
65                                         <xsl:element name="PRIMARY"/>
66                                 </xsl:when>
67                                 <xsl:when test="count(KEY) > 0">
68                                         <xsl:element name="KEY"/>
69                                 </xsl:when>
70                                 <xsl:when test="count(NOTNULL) > 0">
71                                         <xsl:element name="NOTNULL"/>
72                                 </xsl:when>
73                         </xsl:choose>
74
75                         <xsl:choose>
76                                 <xsl:when test="count(AUTO) > 0">
77                                         <xsl:element name="AUTO"/>
78                                 </xsl:when>
79                                 <xsl:when test="count(AUTOINCREMENT) > 0">
80                                         <xsl:element name="AUTOINCREMENT"/>
81                                 </xsl:when>
82                         </xsl:choose>
83
84                         <xsl:choose>
85                                 <xsl:when test="count(DEFAULT) > 0">
86                                         <xsl:element name="DEFAULT">
87                                                 <xsl:attribute name="value">
88                                                         <xsl:value-of select="DEFAULT[1]/@value"/>
89                                                 </xsl:attribute>
90                                         </xsl:element>
91                                 </xsl:when>
92                                 <xsl:when test="count(DEFDATE) > 0">
93                                         <xsl:element name="DEFDATE">
94                                                 <xsl:attribute name="value">
95                                                         <xsl:value-of select="DEFDATE[1]/@value"/>
96                                                 </xsl:attribute>
97                                         </xsl:element>
98                                 </xsl:when>
99                                 <xsl:when test="count(DEFTIMESTAMP) > 0">
100                                         <xsl:element name="DEFTIMESTAMP">
101                                                 <xsl:attribute name="value">
102                                                         <xsl:value-of select="DEFTIMESTAMP[1]/@value"/>
103                                                 </xsl:attribute>
104                                         </xsl:element>
105                                 </xsl:when>
106                         </xsl:choose>
107
108                         <xsl:if test="count(NOQUOTE) > 0">
109                                 <xsl:element name="NOQUOTE"/>
110                         </xsl:if>
111
112                         <xsl:apply-templates select="constraint"/>
113                 </xsl:element>
114         </xsl:template>
115
116         <!-- Constraint -->
117         <xsl:template match="constraint">
118                 <xsl:element name="constraint">
119                         <xsl:value-of select="normalize-space(text())"/>
120                 </xsl:element>
121         </xsl:template>
122
123         <!-- Index -->
124         <xsl:template match="index">
125                 <xsl:element name="index">
126                         <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
127
128                         <xsl:apply-templates select="descr[1]"/>
129
130                         <xsl:if test="count(CLUSTERED) > 0">
131                                 <xsl:element name="CLUSTERED"/>
132                         </xsl:if>
133
134                         <xsl:if test="count(BITMAP) > 0">
135                                 <xsl:element name="BITMAP"/>
136                         </xsl:if>
137
138                         <xsl:if test="count(UNIQUE) > 0">
139                                 <xsl:element name="UNIQUE"/>
140                         </xsl:if>
141
142                         <xsl:if test="count(FULLTEXT) > 0">
143                                 <xsl:element name="FULLTEXT"/>
144                         </xsl:if>
145
146                         <xsl:if test="count(HASH) > 0">
147                                 <xsl:element name="HASH"/>
148                         </xsl:if>
149
150                         <xsl:choose>
151                                 <xsl:when test="count(DROP) > 0">
152                                         <xsl:element name="DROP"/>
153                                 </xsl:when>
154                                 <xsl:otherwise>
155                                         <xsl:apply-templates select="col"/>
156                                 </xsl:otherwise>
157                         </xsl:choose>
158                 </xsl:element>
159         </xsl:template>
160
161         <!-- Index Column -->
162         <xsl:template match="col">
163                 <xsl:element name="col">
164                         <xsl:value-of select="normalize-space(text())"/>
165                 </xsl:element>
166         </xsl:template>
167
168         <!-- SQL QuerySet -->
169         <xsl:template match="sql">
170                 <xsl:element name="sql">
171                         <xsl:if test="string-length(@platform) > 0">
172                                 <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
173                         </xsl:if>
174
175                         <xsl:if test="string-length(@key) > 0">
176                                 <xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
177                         </xsl:if>
178
179                         <xsl:if test="string-length(@prefixmethod) > 0">
180                                 <xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
181                         </xsl:if>
182
183                         <xsl:apply-templates select="descr[1]"/>
184                         <xsl:apply-templates select="query"/>
185                 </xsl:element>
186         </xsl:template>
187
188         <!-- Query -->
189         <xsl:template match="query">
190                 <xsl:element name="query">
191                         <xsl:if test="string-length(@platform) > 0">
192                                 <xsl:attribute name="platform"><xsl:value-of select="@platform"/></xsl:attribute>
193                         </xsl:if>
194
195                         <xsl:value-of select="normalize-space(text())"/>
196                 </xsl:element>
197         </xsl:template>
198
199         <!-- Description -->
200         <xsl:template match="descr">
201                 <xsl:element name="descr">
202                         <xsl:value-of select="normalize-space(text())"/>
203                 </xsl:element>
204         </xsl:template>
205 </xsl:stylesheet>