1 <?xml version=
"1.0" encoding=
"UTF-8"?>
2 <xsl:stylesheet version=
"1.0"
3 xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <xsl:output method=
"xml" indent=
"yes" omit-xml-declaration=
"no" encoding=
"UTF-8"/>
8 <xsl:template match=
"/">
11 http://adodb-xmlschema.sourceforge.net
14 <xsl:element name=
"schema">
15 <xsl:attribute name=
"version">0.3</xsl:attribute>
17 <xsl:apply-templates select=
"schema/table|schema/sql"/>
22 <xsl:template match=
"table">
23 <xsl:variable name=
"table_name" select=
"@name"/>
25 <xsl:element name=
"table">
26 <xsl:attribute name=
"name"><xsl:value-of select=
"$table_name"/></xsl:attribute>
28 <xsl:if test=
"string-length(@platform) > 0">
29 <xsl:attribute name=
"platform"><xsl:value-of select=
"@platform"/></xsl:attribute>
32 <xsl:if test=
"string-length(@version) > 0">
33 <xsl:attribute name=
"version"><xsl:value-of select=
"@version"/></xsl:attribute>
36 <xsl:apply-templates select=
"descr[1]"/>
39 <xsl:when test=
"count(DROP) > 0">
40 <xsl:element name=
"DROP"/>
43 <xsl:apply-templates select=
"field"/>
47 <xsl:apply-templates select=
"constraint"/>
49 <xsl:apply-templates select=
"../index[@table=$table_name]"/>
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>
59 <xsl:if test=
"string-length(@size) > 0">
60 <xsl:attribute name=
"size"><xsl:value-of select=
"@size"/></xsl:attribute>
64 <xsl:when test=
"string-length(@opts) = 0"/>
65 <xsl:when test=
"@opts = 'UNSIGNED'">
66 <xsl:element name=
"UNSIGNED"/>
68 <xsl:when test=
"contains(@opts,'UNSIGNED')">
69 <xsl:attribute name=
"opts">
70 <xsl:value-of select=
"concat(substring-before(@opts,'UNSIGNED'),substring-after(@opts,'UNSIGNED'))"/>
72 <xsl:element name=
"UNSIGNED"/>
75 <xsl:attribute name=
"opts"><xsl:value-of select=
"@opts"/></xsl:attribute>
80 <xsl:when test=
"count(PRIMARY) > 0">
81 <xsl:element name=
"PRIMARY"/>
83 <xsl:when test=
"count(KEY) > 0">
84 <xsl:element name=
"KEY"/>
86 <xsl:when test=
"count(NOTNULL) > 0">
87 <xsl:element name=
"NOTNULL"/>
92 <xsl:when test=
"count(AUTO) > 0">
93 <xsl:element name=
"AUTO"/>
95 <xsl:when test=
"count(AUTOINCREMENT) > 0">
96 <xsl:element name=
"AUTOINCREMENT"/>
101 <xsl:when test=
"count(DEFAULT) > 0">
102 <xsl:element name=
"DEFAULT">
103 <xsl:attribute name=
"value">
104 <xsl:value-of select=
"DEFAULT[1]/@value"/>
108 <xsl:when test=
"count(DEFDATE) > 0">
109 <xsl:element name=
"DEFDATE">
110 <xsl:attribute name=
"value">
111 <xsl:value-of select=
"DEFDATE[1]/@value"/>
115 <xsl:when test=
"count(DEFTIMESTAMP) > 0">
116 <xsl:element name=
"DEFTIMESTAMP">
117 <xsl:attribute name=
"value">
118 <xsl:value-of select=
"DEFTIMESTAMP[1]/@value"/>
124 <xsl:if test=
"count(NOQUOTE) > 0">
125 <xsl:element name=
"NOQUOTE"/>
128 <xsl:apply-templates select=
"constraint"/>
133 <xsl:template match=
"constraint">
134 <xsl:element name=
"constraint">
135 <xsl:value-of select=
"normalize-space(text())"/>
140 <xsl:template match=
"index">
141 <xsl:element name=
"index">
142 <xsl:attribute name=
"name"><xsl:value-of select=
"@name"/></xsl:attribute>
144 <xsl:apply-templates select=
"descr[1]"/>
146 <xsl:if test=
"count(CLUSTERED) > 0">
147 <xsl:element name=
"CLUSTERED"/>
150 <xsl:if test=
"count(BITMAP) > 0">
151 <xsl:element name=
"BITMAP"/>
154 <xsl:if test=
"count(UNIQUE) > 0">
155 <xsl:element name=
"UNIQUE"/>
158 <xsl:if test=
"count(FULLTEXT) > 0">
159 <xsl:element name=
"FULLTEXT"/>
162 <xsl:if test=
"count(HASH) > 0">
163 <xsl:element name=
"HASH"/>
167 <xsl:when test=
"count(DROP) > 0">
168 <xsl:element name=
"DROP"/>
171 <xsl:apply-templates select=
"col"/>
177 <!-- Index Column -->
178 <xsl:template match=
"col">
179 <xsl:element name=
"col">
180 <xsl:value-of select=
"normalize-space(text())"/>
184 <!-- SQL QuerySet -->
185 <xsl:template match=
"sql">
186 <xsl:element name=
"sql">
187 <xsl:if test=
"string-length(@platform) > 0">
188 <xsl:attribute name=
"platform"><xsl:value-of select=
"@platform"/></xsl:attribute>
191 <xsl:if test=
"string-length(@key) > 0">
192 <xsl:attribute name=
"key"><xsl:value-of select=
"@key"/></xsl:attribute>
195 <xsl:if test=
"string-length(@prefixmethod) > 0">
196 <xsl:attribute name=
"prefixmethod"><xsl:value-of select=
"@prefixmethod"/></xsl:attribute>
199 <xsl:apply-templates select=
"descr[1]"/>
200 <xsl:apply-templates select=
"query"/>
205 <xsl:template match=
"query">
206 <xsl:element name=
"query">
207 <xsl:if test=
"string-length(@platform) > 0">
208 <xsl:attribute name=
"platform"><xsl:value-of select=
"@platform"/></xsl:attribute>
211 <xsl:value-of select=
"normalize-space(text())"/>
216 <xsl:template match=
"descr">
217 <xsl:element name=
"descr">
218 <xsl:value-of select=
"normalize-space(text())"/>