Mainly changes to MS-SQL generation

This commit is contained in:
sb 2008-07-10 09:55:30 +00:00
parent 62168723e1
commit 83f163bb60
2 changed files with 23 additions and 15 deletions

View file

@ -116,7 +116,7 @@
</a>
</xsl:when>
<xsl:when test="@type = 'link'">
to entity of type <a>
(many to many) to entities of type <a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '#entity-', @entity)"/>
</xsl:attribute>
@ -124,7 +124,7 @@
</a>
</xsl:when>
<xsl:when test="@type = 'list'">
of entities of type <a>
(one to many) of entities of type <a>
<xsl:attribute name="href">
<xsl:value-of select="concat( '#entity-', @entity)"/>
</xsl:attribute>

View file

@ -12,7 +12,7 @@
Convert ADL to MS-SQL
$Author: sb $
$Revision: 1.5 $
$Revision: 1.6 $
-->
<xsl:output indent="no" encoding="UTF-8" method="text"/>
@ -103,7 +103,8 @@
-- <xsl:value-of select="$product-version"/>
--
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@version"/>
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.5 $', 12)"/>
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.6 $', 12)"/>
-- THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT IT.
--
-- Code generator (c) 2007 Cygnet Solutions Ltd
--
@ -185,6 +186,10 @@
</xsl:template>
<!-- generate referential integrity constraints -->
<!-- there's a sort-of problem with this - if we have properties at both
ends of a link (which we often do) we currently generate two identical
constraints. This doesn't seem to cause any major problems but must hurt
efficiency. It would be better if we fixed this. -->
<xsl:template match="adl:entity" mode="refinteg">
<xsl:variable name="nearside" select="@name"/>
<xsl:for-each select="descendant::adl:property[@type='entity']">
@ -208,20 +213,23 @@
</xsl:choose>
</xsl:for-each>
<xsl:for-each select="descendant::adl:property[@type='list']">
<xsl:variable name="farkey">
<xsl:choose>
<xsl:when test="@farkey">
<xsl:value-of select="@farkey"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="../@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="ns2" select="@entity"/>
<xsl:variable name="linkfield">
<xsl:call-template name="property-column-name">
<xsl:with-param name="property"
select="//adl:entity[@name=$ns2]//adl:property[@entity=$nearside]"/>
</xsl:call-template>
</xsl:variable>
<xsl:if test="string-length( $linkfield) = 0">
<xsl:message terminate="yes">
ADL: ERROR: Failed to infer link field name whilst processing list property <xsl:value-of select="@name"/> of <xsl:value-of select="ancestor::adl:entity/@name"/>
Entity is '<xsl:value-of select="$ns2"/>', nearside is '<xsl:value-of select="$nearside"/>'
</xsl:message>
</xsl:if>
<xsl:call-template name="foreignkey">
<xsl:with-param name="nearside" select="@entity"/>
<xsl:with-param name="farside" select="../@name"/>
<xsl:with-param name="linkfield" select="$farkey"/>
<xsl:with-param name="linkfield" select="$linkfield"/>
<xsl:with-param name="ondelete">
<xsl:choose>
<xsl:when test="@cascade='all'">CASCADE</xsl:when>