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.2</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="count(PRIMARY) > 0">
65 <xsl:element name="PRIMARY"/>
67 <xsl:when test="count(KEY) > 0">
68 <xsl:element name="KEY"/>
70 <xsl:when test="count(NOTNULL) > 0">
71 <xsl:element name="NOTNULL"/>
76 <xsl:when test="count(AUTO) > 0">
77 <xsl:element name="AUTO"/>
79 <xsl:when test="count(AUTOINCREMENT) > 0">
80 <xsl:element name="AUTOINCREMENT"/>
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"/>
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"/>
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"/>
108 <xsl:if test="count(NOQUOTE) > 0">
109 <xsl:element name="NOQUOTE"/>
112 <xsl:apply-templates select="constraint"/>
117 <xsl:template match="constraint">
118 <xsl:element name="constraint">
119 <xsl:value-of select="normalize-space(text())"/>
124 <xsl:template match="index">
125 <xsl:element name="index">
126 <xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>
128 <xsl:apply-templates select="descr[1]"/>
130 <xsl:if test="count(CLUSTERED) > 0">
131 <xsl:element name="CLUSTERED"/>
134 <xsl:if test="count(BITMAP) > 0">
135 <xsl:element name="BITMAP"/>
138 <xsl:if test="count(UNIQUE) > 0">
139 <xsl:element name="UNIQUE"/>
142 <xsl:if test="count(FULLTEXT) > 0">
143 <xsl:element name="FULLTEXT"/>
146 <xsl:if test="count(HASH) > 0">
147 <xsl:element name="HASH"/>
151 <xsl:when test="count(DROP) > 0">
152 <xsl:element name="DROP"/>
155 <xsl:apply-templates select="col"/>
161 <!-- Index Column -->
162 <xsl:template match="col">
163 <xsl:element name="col">
164 <xsl:value-of select="normalize-space(text())"/>
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>
175 <xsl:if test="string-length(@key) > 0">
176 <xsl:attribute name="key"><xsl:value-of select="@key"/></xsl:attribute>
179 <xsl:if test="string-length(@prefixmethod) > 0">
180 <xsl:attribute name="prefixmethod"><xsl:value-of select="@prefixmethod"/></xsl:attribute>
183 <xsl:apply-templates select="descr[1]"/>
184 <xsl:apply-templates select="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>
195 <xsl:value-of select="normalize-space(text())"/>
200 <xsl:template match="descr">
201 <xsl:element name="descr">
202 <xsl:value-of select="normalize-space(text())"/>