36 |
kaklik |
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.3</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="string-length(@opts) = 0"/>
|
|
|
65 |
<xsl:when test="@opts = 'UNSIGNED'">
|
|
|
66 |
<xsl:element name="UNSIGNED"/>
|
|
|
67 |
</xsl:when>
|
|
|
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'))"/>
|
|
|
71 |
</xsl:attribute>
|
|
|
72 |
<xsl:element name="UNSIGNED"/>
|
|
|
73 |
</xsl:when>
|
|
|
74 |
<xsl:otherwise>
|
|
|
75 |
<xsl:attribute name="opts"><xsl:value-of select="@opts"/></xsl:attribute>
|
|
|
76 |
</xsl:otherwise>
|
|
|
77 |
</xsl:choose>
|
|
|
78 |
|
|
|
79 |
<xsl:choose>
|
|
|
80 |
<xsl:when test="count(PRIMARY) > 0">
|
|
|
81 |
<xsl:element name="PRIMARY"/>
|
|
|
82 |
</xsl:when>
|
|
|
83 |
<xsl:when test="count(KEY) > 0">
|
|
|
84 |
<xsl:element name="KEY"/>
|
|
|
85 |
</xsl:when>
|
|
|
86 |
<xsl:when test="count(NOTNULL) > 0">
|
|
|
87 |
<xsl:element name="NOTNULL"/>
|
|
|
88 |
</xsl:when>
|
|
|
89 |
</xsl:choose>
|
|
|
90 |
|
|
|
91 |
<xsl:choose>
|
|
|
92 |
<xsl:when test="count(AUTO) > 0">
|
|
|
93 |
<xsl:element name="AUTO"/>
|
|
|
94 |
</xsl:when>
|
|
|
95 |
<xsl:when test="count(AUTOINCREMENT) > 0">
|
|
|
96 |
<xsl:element name="AUTOINCREMENT"/>
|
|
|
97 |
</xsl:when>
|
|
|
98 |
</xsl:choose>
|
|
|
99 |
|
|
|
100 |
<xsl:choose>
|
|
|
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"/>
|
|
|
105 |
</xsl:attribute>
|
|
|
106 |
</xsl:element>
|
|
|
107 |
</xsl:when>
|
|
|
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"/>
|
|
|
112 |
</xsl:attribute>
|
|
|
113 |
</xsl:element>
|
|
|
114 |
</xsl:when>
|
|
|
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"/>
|
|
|
119 |
</xsl:attribute>
|
|
|
120 |
</xsl:element>
|
|
|
121 |
</xsl:when>
|
|
|
122 |
</xsl:choose>
|
|
|
123 |
|
|
|
124 |
<xsl:if test="count(NOQUOTE) > 0">
|
|
|
125 |
<xsl:element name="NOQUOTE"/>
|
|
|
126 |
</xsl:if>
|
|
|
127 |
|
|
|
128 |
<xsl:apply-templates select="constraint"/>
|
|
|
129 |
</xsl:element>
|
|
|
130 |
</xsl:template>
|
|
|
131 |
|
|
|
132 |
<!-- Constraint -->
|
|
|
133 |
<xsl:template match="constraint">
|
|
|
134 |
<xsl:element name="constraint">
|
|
|
135 |
<xsl:value-of select="normalize-space(text())"/>
|
|
|
136 |
</xsl:element>
|
|
|
137 |
</xsl:template>
|
|
|
138 |
|
|
|
139 |
<!-- Index -->
|
|
|
140 |
<xsl:template match="index">
|
|
|
141 |
<xsl:element name="index">
|
|
|
142 |
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
|
|
|
143 |
|
|
|
144 |
<xsl:apply-templates select="descr[1]"/>
|
|
|
145 |
|
|
|
146 |
<xsl:if test="count(CLUSTERED) > 0">
|
|
|
147 |
<xsl:element name="CLUSTERED"/>
|
|
|
148 |
</xsl:if>
|
|
|
149 |
|
|
|
150 |
<xsl:if test="count(BITMAP) > 0">
|
|
|
151 |
<xsl:element name="BITMAP"/>
|
|
|
152 |
</xsl:if>
|
|
|
153 |
|
|
|
154 |
<xsl:if test="count(UNIQUE) > 0">
|
|
|
155 |
<xsl:element name="UNIQUE"/>
|
|
|
156 |
</xsl:if>
|
|
|
157 |
|
|
|
158 |
<xsl:if test="count(FULLTEXT) > 0">
|
|
|
159 |
<xsl:element name="FULLTEXT"/>
|
|
|
160 |
</xsl:if>
|
|
|
161 |
|
|
|
162 |
<xsl:if test="count(HASH) > 0">
|
|
|
163 |
<xsl:element name="HASH"/>
|
|
|
164 |
</xsl:if>
|
|
|
165 |
|
|
|
166 |
<xsl:choose>
|
|
|
167 |
<xsl:when test="count(DROP) > 0">
|
|
|
168 |
<xsl:element name="DROP"/>
|
|
|
169 |
</xsl:when>
|
|
|
170 |
<xsl:otherwise>
|
|
|
171 |
<xsl:apply-templates select="col"/>
|
|
|
172 |
</xsl:otherwise>
|
|
|
173 |
</xsl:choose>
|
|
|
174 |
</xsl:element>
|
|
|
175 |
</xsl:template>
|
|
|
176 |
|
|
|
177 |
<!-- Index Column -->
|
|
|
178 |
<xsl:template match="col">
|
|
|
179 |
<xsl:element name="col">
|
|
|
180 |
<xsl:value-of select="normalize-space(text())"/>
|
|
|
181 |
</xsl:element>
|
|
|
182 |
</xsl:template>
|
|
|
183 |
|
|
|
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>
|
|
|
189 |
</xsl:if>
|
|
|
190 |
|
|
|
191 |
<xsl:if test="string-length(@key) > 0">
|
|
|
192 |
<xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
|
|
|
193 |
</xsl:if>
|
|
|
194 |
|
|
|
195 |
<xsl:if test="string-length(@prefixmethod) > 0">
|
|
|
196 |
<xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
|
|
|
197 |
</xsl:if>
|
|
|
198 |
|
|
|
199 |
<xsl:apply-templates select="descr[1]"/>
|
|
|
200 |
<xsl:apply-templates select="query"/>
|
|
|
201 |
</xsl:element>
|
|
|
202 |
</xsl:template>
|
|
|
203 |
|
|
|
204 |
<!-- 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>
|
|
|
209 |
</xsl:if>
|
|
|
210 |
|
|
|
211 |
<xsl:value-of select="normalize-space(text())"/>
|
|
|
212 |
</xsl:element>
|
|
|
213 |
</xsl:template>
|
|
|
214 |
|
|
|
215 |
<!-- Description -->
|
|
|
216 |
<xsl:template match="descr">
|
|
|
217 |
<xsl:element name="descr">
|
|
|
218 |
<xsl:value-of select="normalize-space(text())"/>
|
|
|
219 |
</xsl:element>
|
|
|
220 |
</xsl:template>
|
|
|
221 |
</xsl:stylesheet>
|