db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r417546 - in /db/torque/site/trunk/xdocs/tools: ./ D4-Torque.xslt index.xml
Date Tue, 27 Jun 2006 18:22:13 GMT
Author: tv
Date: Tue Jun 27 11:22:13 2006
New Revision: 417546

URL: http://svn.apache.org/viewvc?rev=417546&view=rev
Log:
Added DBDesigner-to-Torque translator and some docs.

Added:
    db/torque/site/trunk/xdocs/tools/
    db/torque/site/trunk/xdocs/tools/D4-Torque.xslt
    db/torque/site/trunk/xdocs/tools/index.xml

Added: db/torque/site/trunk/xdocs/tools/D4-Torque.xslt
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/tools/D4-Torque.xslt?rev=417546&view=auto
==============================================================================
--- db/torque/site/trunk/xdocs/tools/D4-Torque.xslt (added)
+++ db/torque/site/trunk/xdocs/tools/D4-Torque.xslt Tue Jun 27 11:22:13 2006
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+	<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" doctype-system="http://db.apache.org/torque/dtd/database_3_2.dtd"/>
+
+	<xsl:template match="/">
+		<xsl:apply-templates/>
+	</xsl:template>
+
+	<xsl:template match="DBMODEL">
+		<database>
+			<xsl:attribute name="name">
+				<xsl:value-of select="SETTINGS/GLOBALSETTINGS/@ModelName"/>
+			</xsl:attribute>
+			<xsl:apply-templates/>
+		</database>
+	</xsl:template>
+
+	<xsl:template match="METADATA">
+		<xsl:apply-templates/>
+	</xsl:template>
+
+	<xsl:template match="TABLES">
+		<xsl:for-each select="TABLE[@Tablename]">
+			<table>
+				<xsl:attribute name="name">
+					<xsl:value-of select="@Tablename"/>
+				</xsl:attribute>
+				<xsl:choose>
+					<xsl:when test="@nmTable = 1">
+						<xsl:attribute name="idMethod">none</xsl:attribute>
+					</xsl:when>
+					<xsl:otherwise>
+						<xsl:attribute name="idMethod">native</xsl:attribute>
+					</xsl:otherwise>
+				</xsl:choose>
+				<xsl:apply-templates/>
+			</table>
+		</xsl:for-each>
+	</xsl:template>
+
+	<xsl:template match="COLUMNS">
+		<xsl:for-each select="COLUMN[@ColName]">
+			<column>
+				<xsl:attribute name="name">
+					<xsl:value-of select="@ColName"/>
+				</xsl:attribute>
+				<xsl:if test="@PrimaryKey = 1">
+					<xsl:attribute name="primaryKey">true</xsl:attribute>
+				</xsl:if>
+				<xsl:if test="@NotNull = 1">
+					<xsl:attribute name="required">true</xsl:attribute>
+				</xsl:if>
+				<xsl:if test="@AutoInc = 1">
+					<xsl:attribute name="autoIncrement">true</xsl:attribute>
+				</xsl:if>
+				<xsl:if test="@idDatatype = 20">
+					<!-- VARCHAR -->
+					<xsl:attribute name="size">
+						<xsl:value-of select="substring-after(substring-before(@DatatypeParams, ')'),'(')"/>
+					</xsl:attribute>
+				</xsl:if>
+				<xsl:attribute name="type">
+					<xsl:variable name="d" select="@idDatatype"/>
+					<xsl:for-each select="//DATATYPE[@ID=$d]">
+						<xsl:choose>
+							<xsl:when test="@PhysicalMapping = 1">
+								<xsl:choose>
+									<xsl:when test="contains(@PhysicalTypeName, 'BOOL')">BOOLEANINT</xsl:when>
+									<xsl:when test="contains(@PhysicalTypeName, 'DATETIME')">TIMESTAMP</xsl:when>
+									<xsl:when test="contains(@PhysicalTypeName, 'MEDIUMTEXT')">LONGVARCHAR</xsl:when>
+									<xsl:otherwise>
+										<xsl:value-of select="@PhysicalTypeName"/>
+									</xsl:otherwise>
+								</xsl:choose>
+							</xsl:when>
+							<xsl:otherwise>
+								<xsl:choose>
+									<xsl:when test="contains(@TypeName, 'BOOL')">BOOLEANINT</xsl:when>
+									<xsl:when test="contains(@TypeName, 'DATETIME')">TIMESTAMP</xsl:when>
+									<xsl:when test="contains(@TypeName, 'MEDIUMTEXT')">LONGVARCHAR</xsl:when>
+									<xsl:otherwise>
+										<xsl:value-of select="@TypeName"/>
+									</xsl:otherwise>
+								</xsl:choose>
+							</xsl:otherwise>
+						</xsl:choose>
+					</xsl:for-each>
+				</xsl:attribute>
+				<xsl:if test="string-length(@DefaultValue) &gt; 0">
+					<xsl:attribute name="default">
+						<xsl:value-of select="@DefaultValue"/>
+					</xsl:attribute>
+				</xsl:if>
+				<xsl:apply-templates/>
+			</column>
+		</xsl:for-each>
+	</xsl:template>
+
+	<xsl:template match="RELATIONS_END">
+		<xsl:for-each select="RELATION_END[@ID]">
+			<foreign-key>
+				<xsl:variable name="id" select="@ID"/>
+				<xsl:for-each select="//RELATION[@ID=$id]">
+					<xsl:variable name="t" select="@SrcTable"/>
+					<xsl:for-each select="//TABLE[@ID=$t]">
+						<xsl:attribute name="foreignTable">
+							<xsl:value-of select="@Tablename"/>
+						</xsl:attribute>
+					</xsl:for-each>
+					<xsl:if test="@CreateRefDef = 1">
+						<xsl:attribute name="onUpdate">
+							<xsl:choose>
+								<xsl:when test="contains(@RefDef, 'OnUpdate=0')">restrict</xsl:when>
+								<xsl:when test="contains(@RefDef, 'OnUpdate=1')">cascade</xsl:when>
+								<xsl:when test="contains(@RefDef, 'OnUpdate=2')">setnull</xsl:when>
+								<xsl:otherwise>none</xsl:otherwise>
+							</xsl:choose>
+						</xsl:attribute>
+						<xsl:attribute name="onDelete">
+							<xsl:choose>
+								<xsl:when test="contains(@RefDef, 'OnDelete=0')">restrict</xsl:when>
+								<xsl:when test="contains(@RefDef, 'OnDelete=1')">cascade</xsl:when>
+								<xsl:when test="contains(@RefDef, 'OnDelete=2')">setnull</xsl:when>
+								<xsl:otherwise>none</xsl:otherwise>
+							</xsl:choose>
+						</xsl:attribute>
+					</xsl:if>
+					<reference>
+						<xsl:attribute name="local">
+							<xsl:value-of select="substring-after(substring-before(@FKFields, '\'), '=')"/>
+						</xsl:attribute>
+						<xsl:attribute name="foreign">
+							<xsl:value-of select="substring-before(@FKFields,'=')"/>
+						</xsl:attribute>
+					</reference>
+				</xsl:for-each>
+				<xsl:apply-templates/>
+			</foreign-key>
+		</xsl:for-each>
+	</xsl:template>
+
+	<xsl:template match="INDICES">
+		<xsl:for-each select="INDEX[@ID]">
+			<xsl:choose>
+				<xsl:when test="@IndexKind = 1">
+					<index>
+						<xsl:attribute name="name">
+							<xsl:value-of select="@IndexName"/>
+						</xsl:attribute>
+						<xsl:for-each select="INDEXCOLUMNS/INDEXCOLUMN[@idColumn]">
+						<index-column>
+							<xsl:variable name="c" select="@idColumn"/>
+							<xsl:for-each select="//COLUMN[@ID=$c]">
+								<xsl:attribute name="name">
+									<xsl:value-of select="@ColName"/>
+								</xsl:attribute>
+							</xsl:for-each>
+						</index-column>
+						</xsl:for-each>
+					</index>
+				</xsl:when>
+				<xsl:when test="@IndexKind = 2">
+					<unique>
+						<xsl:attribute name="name">
+							<xsl:value-of select="@IndexName"/>
+						</xsl:attribute>
+						<xsl:for-each select="INDEXCOLUMNS/INDEXCOLUMN[@idColumn]">
+						<unique-column>
+							<xsl:variable name="c" select="@idColumn"/>
+							<xsl:for-each select="//COLUMN[@ID=$c]">
+								<xsl:attribute name="name">
+									<xsl:value-of select="@ColName"/>
+								</xsl:attribute>
+							</xsl:for-each>
+						</unique-column>
+						</xsl:for-each>
+					</unique>
+				</xsl:when>
+			</xsl:choose>
+		</xsl:for-each>
+	</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file

Added: db/torque/site/trunk/xdocs/tools/index.xml
URL: http://svn.apache.org/viewvc/db/torque/site/trunk/xdocs/tools/index.xml?rev=417546&view=auto
==============================================================================
--- db/torque/site/trunk/xdocs/tools/index.xml (added)
+++ db/torque/site/trunk/xdocs/tools/index.xml Tue Jun 27 11:22:13 2006
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2001-2006 The Apache Software Foundation.
+
+ Licensed under the Apache License, Version 2.0 (the "License")
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<document>
+  <properties>
+    <title>Transforming DBDesigner Schemas into Torque Format</title>
+    <author email="tv@apache.org">Thomas Vandahl</author>
+  </properties>
+
+  <body>
+   <section name="D4-Torque.xslt">
+     <p>
+       <a href="http://fabforce.net/dbdesigner4/">DBDesigner</a> is a tool which

+       helps with database design. It is made for MySQL databases, mostly. 
+       DBDesigner kindly stores the model in XML files which contain most 
+       information that we need in the Torque schema. So this script was
+       created to transform one form into the other.
+     </p>
+     <p>
+       To use the script <a href="D4-Torque.xslt"><code>D4-Torque.xslt</code></a>,
+       simply fire up the XSLT-processor of your choice and give it the DBDesigner
+       model as an input.
+     </p>
+   </section>
+   <section name="Status">
+     <p>
+       This script was made for transforming a certain model into the associated
+       Torque schema. So basically, &quot;It works for me&quot;. Mostly the mapping
+       of DBDesigner types into Torque types is incomplete. Any patches are welcome
+       (as always).
+     </p>
+     <p>
+       DBDesigner is no longer actively being developed. It's successor,
+       <a href="http://dev.mysql.com/downloads/workbench/">MySQL Workbench</a>,
+       is currently in Beta status. As far as we can see, the format of the
+       model files will need adjustment when it's ready.
+     </p>
+   </section>
+  </body>
+</document>



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message