Bringing into line with current b_development

This commit is contained in:
sb 2008-10-02 10:43:42 +00:00
parent ffbdce8989
commit d5c557f93e
8 changed files with 1156 additions and 199 deletions

View file

@ -13,12 +13,13 @@
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- <!--
$Revision: 1.17 $ $Revision: 1.18 $
--> -->
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- Before we start: import XHTML --> <!-- Before we start: import XHTML for use in documentation sections -->
<!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: --> <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
<!-- doesn't work yet -->
<!-- ENTITY % XHTML PUBLIC <!-- ENTITY % XHTML PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@ -168,13 +169,15 @@ that we can allow HTML block level entities within content elements -->
name: the name of this application name: the name of this application
version: the version number of this application version: the version number of this application
revision: the revision of the ADL document revision: the revision of the ADL document
currency: the base monetary currency, in the form of an ISO 4217 three-letter code
xmlns: XML namespace, in case required xmlns: XML namespace, in case required
--> -->
<!ELEMENT application ( documentation?, content?, typedef*, group*, entity*)> <!ELEMENT application ( specification?, documentation?, content?, typedef*, group*, entity*)>
<!ATTLIST application <!ATTLIST application
name CDATA #REQUIRED name CDATA #REQUIRED
version CDATA #IMPLIED version CDATA #IMPLIED
revision CDATA #IMPLIED revision CDATA #IMPLIED
currency CDATA #IMPLIED
xmlns CDATA #IMPLIED> xmlns CDATA #IMPLIED>
<!-- <!--
@ -251,7 +254,7 @@ that we can allow HTML block level entities within content elements -->
for it, although code which links to it will be generated for it, although code which links to it will be generated
--> -->
<!ELEMENT entity ( documentation?, content?, key?, <!ELEMENT entity ( documentation?, content?, key?,
(property | one-to-many | many-to-many | many-to-one)*, (property)*,
permission*, (form | page | list)*)> permission*, (form | page | list)*)>
<!ATTLIST entity <!ATTLIST entity
name CDATA #REQUIRED name CDATA #REQUIRED
@ -264,7 +267,7 @@ that we can allow HTML block level entities within content elements -->
should HTML markup within a documentation element be allowed? If so, are should HTML markup within a documentation element be allowed? If so, are
there restrictions? there restrictions?
--> -->
<!ELEMENT documentation (#PCDATA)> <!ELEMENT documentation ( #PCDATA|reference)*>
<!ATTLIST documentation <!ATTLIST documentation
xmlns CDATA #IMPLIED> xmlns CDATA #IMPLIED>
@ -327,117 +330,6 @@ that we can allow HTML block level entities within content elements -->
concrete %Boolean; #IMPLIED concrete %Boolean; #IMPLIED
cascade (%CascadeActions;) #IMPLIED> cascade (%CascadeActions;) #IMPLIED>
<!-- It may be worth extracting properties which are not 'simple' into separate elements; this is equivalent to
property[@type='list']. TODO: Not complete, not yet strictly convinced it's the right solution -->
<!--
a property whose value is a set of entities
name: the name of this property.
entity: if type='entity', the name of the entity this property is
a foreign key link to.
if type='list', the name of the entity that has a foreign
key link to this entity
farkey: if type='list', the name of farside key in the listed
entity
required: whether this propery is required (i.e. 'not null').
concrete: if set to 'false', this property is not stored in the
database but must be computed (manually written code must
be provided to support this)
cascade: what action(s) on the parent entity should be cascaded to
entitie(s) linked on this property. Valid only if type='entity',
type='link' or type='list'.
column: name of the column in a SQL database table in which this property
is stored. TODO: Think about this.
unsaved-value:
of a property whose persistent value is set on first being
committed to persistent store, the value which it holds before
it has been committed
-->
<!ELEMENT one-to-many (documentation?)>
<!ATTLIST one-to-many
name CDATA #REQUIRED
distinct (none|all|user|system) #IMPLIED
entity CDATA #IMPLIED
farkey CDATA #IMPLIED
required %Boolean; #IMPLIED
concrete %Boolean; #IMPLIED
cascade (%CascadeActions;) #IMPLIED
column CDATA #IMPLIED
unsaved-value CDATA #IMPLIED>
<!-- It may be worth extracting properties which are not 'simple' into separate elements; this is equivalent to
property[@type='link']. TODO: Not complete, not yet strictly convinced it's the right solution -->
<!--
a pseudo-property whose value is a set of entities
TODO: maybe should have an optional attribute for the name of the linking table
name: the name of this property.
entity: if type='entity', the name of the entity this property is
a foreign key link to.
if type='list', the name of the entity that has a foreign
key link to this entity
farkey: if type='list', the name of farside key in the listed
entity
required: whether this propery is required (i.e. 'not null').
concrete: if set to 'false', this property is not stored in the
database but must be computed (manually written code must
be provided to support this)
cascade: what action(s) on the parent entity should be cascaded to
entitie(s) linked on this property. Valid only if type='entity',
type='link' or type='list'.
column: name of the column in a SQL database table in which this property
is stored. TODO: Think about this.
unsaved-value:
of a property whose persistent value is set on first being
committed to persistent store, the value which it holds before
it has been committed
-->
<!ELEMENT many-to-many (documentation?)>
<!ATTLIST many-to-many
name CDATA #REQUIRED
distinct (none|all|user|system) #IMPLIED
entity CDATA #IMPLIED
farkey CDATA #IMPLIED
required %Boolean; #IMPLIED
concrete %Boolean; #IMPLIED
cascade (%CascadeActions;) #IMPLIED
column CDATA #IMPLIED
unsaved-value CDATA #IMPLIED>
<!-- It may be worth extracting properties which are not 'simple' into separate elements; this is equivalent to
property[@type='entity']. TODO: Not complete, not yet strictly convinced it's the right solution.
-->
<!--
a property whose value is an entity
TODO: should this have an attribute 'default'?
name: the name of this property.
entity: the name of the entity this property is
a foreign key link to.
required: whether this propery is required (i.e. 'not null').
concrete: if set to 'false', this property is not stored in the
database but must be computed (manually written code must
be provided to support this)
cascade: what action(s) on the parent entity should be cascaded to
entitie(s) linked on this property. Valid only if type='entity',
type='link' or type='list'.
column: name of the column in a SQL database table in which this property
is stored. TODO: Think about this.
unsaved-value:
of a property whose persistent value is set on first being
committed to persistent store, the value which it holds before
it has been committed
-->
<!ELEMENT many-to-one (documentation?)>
<!ATTLIST many-to-one
name CDATA #REQUIRED
distinct (none|all|user|system) #IMPLIED
entity CDATA #IMPLIED
farkey CDATA #IMPLIED
required %Boolean; #IMPLIED
concrete %Boolean; #IMPLIED
cascade (%CascadeActions;) #IMPLIED
column CDATA #IMPLIED
unsaved-value CDATA #IMPLIED>
<!-- <!--
marks a property which is auto-generated by some part of the system. marks a property which is auto-generated by some part of the system.
@ -660,5 +552,46 @@ property[@type='entity']. TODO: Not complete, not yet strictly convinced it's th
<!ATTLIST foot <!ATTLIST foot
xmlns CDATA #IMPLIED> xmlns CDATA #IMPLIED>
<!--
The 'specification' and 'reference' elements are for documentation only,
and do not contribute to the engineering of the application described.
A specification element is intended chiefly to declare the reference
documents which may be used in documentation elements later in the
document.
url: The URL from which the document referenced can be retrieved
name: The full name (title) given to this document
abbr: A convenient abbreviated name
-->
<!ELEMENT specification (documentation?, reference*)>
<!ATTLIST specification
url CDATA #IMPLIED
name CDATA #REQUIRED
abbr CDATA #REQUIRED
>
<!--
The 'specification' and 'reference' elements are for documentation only,
and do not contribute to the engineering of the application described.
A reference element is a reference to a specifying document.
abbr: The abbreviated name of the specification to which this
reference refers
section: The 'anchor part' (part following a hash character) which,
when appended to the URL, will locate the exact section
referenced.
entity: A reference to another entity within this ADL document
property: A reference to another property within this ADL document;
if entity is also specified then of that entity, else of
the ancestor entity if any
-->
<!ELEMENT reference (documentation?)>
<!ATTLIST reference
abbr CDATA #IMPLIED
section CDATA #IMPLIED
entity CDATA #IMPLIED
property CDATA #IMPLIED
>

715
transforms/adl2activerecord.xslt Executable file
View file

@ -0,0 +1,715 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Application Description Language framework
adl2activerecord.xslt
(c) 2008 Cygnet Solutions Ltd
Transform ADL into ActiveRecord conforming entity classes
$Author: sb $
$Revision: 1.2 $
$Date: 2008-10-02 10:43:42 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:exsl="http://exslt.org/common"
xmlns:adl="http://cygnets.co.uk/schemas/adl-1.2"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<!-- NOTE NOTE NOTE:
deliberately does NOT include 'csharp-type-include' as ActiveRecord appears to
need slightly different base types from NHibernate
-->
<xsl:include href="base-type-include.xslt"/>
<xsl:output encoding="UTF-8" method="text"/>
<!-- The locale for which these entities are generated
TODO: Entities should NOT be locale specific. Instead, the
entity should generate messages based on the
client's locale. However, there may still need to be a concept of a
'default locale', for when we don't have messages which suit the
client's locale -->
<xsl:param name="locale" select="en-GB"/>
<!-- The C# namespace within which I shall generate controllers -->
<xsl:param name="controllerns" select="Unset"/>
<!-- The C# namespace within which I shall generate entities -->
<xsl:param name="entityns" select="Unset"/>
<!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- strings used in normalising names for constants.
NOTE NOTE NOTE:
this deliberately converts space and punctuation to underscore -->
<xsl:variable name="notpermittedinconstantname">abcdefghijklmnopqrstuvwxyz .,;:?/()</xsl:variable>
<xsl:variable name="permittedinconstantname">ABCDEFGHIJKLMNOPQRSTUVWXYZ_________</xsl:variable>
<xsl:template match="adl:application">
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
//-------------------------------------------------------------
//
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="@name"/>.auto.cs
//
// (c)2007 Cygnet Solutions Ltd
//
// Main application entry point for <xsl:value-of select="@name"/>
// Automatically generated from application description using
// adl2activerecord.xsl revision <xsl:value-of select="substring( '$Revision: 1.2 $', 10)"/>
//
// <xsl:value-of select="/adl:application/@revision"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
//-------------------------------------------------------------
using System;
using System.Windows.Forms;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework.Config;
using Cygnet.Entities;
namespace <xsl:value-of select="$entityns"/>
{
/// &lt;summary&gt;
/// <xsl:value-of select="normalize-space( adl:documentation)"/>
/// &lt;/summary&gt;
/// &lt;remarks&gt;
/// Automatically generated from description of application <xsl:value-of select="@name"/>
/// using adl2activerecord.xsl revision <xsl:value-of select="substring( '$Revision: 1.2 $', 10)"/>.
/// Note that manually maintained parts of this class may be defined in
/// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v.
///
/// DO NOT EDIT THIS FILE!
/// &lt;/remarks&gt;
public class <xsl:value-of select="@name"/>
{
public static void Main()
{
XmlConfigurationSource source = new XmlConfigurationSource("appconfig.xml");
ActiveRecordStarter.Initialize( source
<xsl:for-each select="adl:entity">
, typeof( <xsl:value-of select="@name"/>)
</xsl:for-each>);
}
}
}
/* ---- [ cut here: next file 'junk'] ------------------------- */
<xsl:apply-templates select="adl:entity"/>
</xsl:template>
<!-- Don't bother generating anything for foreign entities -->
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:entity">
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
//-------------------------------------------------------------
//
// <xsl:value-of select="$product-version"/>
// <xsl:value-of select="@name"/>.auto.cs
//
// (c)2007 Cygnet Solutions Ltd
//
// Automatically generated from application description using
// adl2activerecord.xsl revision <xsl:value-of select="substring( '$Revision: 1.2 $', 10)"/>
//
// <xsl:value-of select="/adl:application/@revision"/>
//
// This file is automatically generated; DO NOT EDIT IT.
//
//-------------------------------------------------------------
using System;
using System.Text;
using System.Collections.Generic;
using Castle.ActiveRecord;
using Cygnet.Entities;
using Cygnet.Exceptions;
using Cygnet.Entities.Exceptions;
namespace <xsl:value-of select="$entityns"/>
{
/// &lt;summary&gt;
/// <xsl:value-of select="normalize-space( adl:documentation)"/>
/// &lt;/summary&gt;
/// &lt;remarks&gt;
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
/// using adl2activerecord.xsl revision <xsl:value-of select="substring( '$Revision: 1.2 $', 10)"/>.
/// Note that manually maintained parts of this class may be defined in
/// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v.
///
/// DO NOT EDIT THIS FILE!
/// &lt;/remarks&gt;
[ActiveRecord]
public partial class <xsl:value-of select="@name"/> : AdlActiveRecord&lt;<xsl:value-of select="@name"/>&gt;
{
/// &lt;summary&gt;
/// Auto-generated no-args constructor; does nothing (but probably should
/// ensure ID slot is initialised correctly)
/// &lt;/summary&gt;
public <xsl:value-of select="@name"/>() : base(){
<xsl:call-template name="initialise-lists"/>
}
<xsl:choose>
<xsl:when test="@natural-key">
/* natural primary key exists - not generating abstract key */
</xsl:when>
<xsl:when test="adl:key">
/* primary key exists - not generating abstract key */
/// &lt;summary&gt;
/// Auto-generated constructor; initialises each of the slots within
/// the primary key and also all one-to-many and many-to-many slots
/// &lt;/summary&gt;
public <xsl:value-of select="@name"/>( <xsl:for-each select="adl:key/adl:property">
<xsl:variable name="csharp-type">
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat( $csharp-type, ' ', @name)"/>
<xsl:if test="not( position() = last())">, </xsl:if>
</xsl:for-each>){
<xsl:call-template name="initialise-lists"/>
<xsl:call-template name="initialise-messages"/>
<xsl:for-each select="adl:key/adl:property">
this.<xsl:value-of select="@name"/> = <xsl:value-of select="@name"/>;
</xsl:for-each>
}
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: Entity '<xsl:value-of select="@name"/>' has no key. Was the
canonicalise stage missed in the build process?
</xsl:message>
</xsl:otherwise>
</xsl:choose>
/// &lt;summary&gt;
/// Auto-generated overridden property for the Key slot, maps onto
/// <xsl:for-each select="adl:key/adl:property">
/// <xsl:value-of select="@name"/><xsl:if test="@type='entity'">.KeyString</xsl:if></xsl:for-each>
/// &lt;/summary&gt;
public override string KeyString {
get {
StringBuilder result = new StringBuilder();
<xsl:for-each select="adl:key/adl:property">
result.Append(<xsl:value-of select="@name"/><xsl:if test="@type='entity'">.KeyString</xsl:if>);
<xsl:if test="position()!=last()">
result.Append('|');
</xsl:if>
</xsl:for-each>
return result.ToString();
}
}
/// &lt;summary&gt;
/// A user readable distinct identifying string
/// &lt;/summary&gt;
public override string UserIdentifier
{
get {
StringBuilder result = new StringBuilder();
<xsl:choose>
<xsl:when test="descendant::adl:property[@distinct='user' or @distinct='all']">
<xsl:for-each select="descendant::adl:property[@distinct='user' or @distinct='all']">
<xsl:choose>
<xsl:when test="@type='message'">
if ( <xsl:value-of select="@name"/> != null){
result.Append( <xsl:value-of select="concat( @name, '.LocalText')"/>);
}
</xsl:when>
<xsl:when test="@type='entity'">
<!-- TODO: this is dangerous and could potentially give rise to
infinite loops; find a way of stopping it running away! -->
if ( <xsl:value-of select="@name"/> != null){
result.Append( <xsl:value-of select="concat( @name, '.UserIdentifier')"/>);
}
</xsl:when>
<xsl:when test="@type='date'">
<!-- if what we've got is just a date, we only want to see the date part of it -->
if ( <xsl:value-of select="@name"/> != null){
result.Append(<xsl:value-of select="@name"/>.ToString( "d"));
}
</xsl:when>
<xsl:when test="@type='time'">
<!-- if what we've got is just a time, we only want to see the time part of it -->
if ( <xsl:value-of select="@name"/> != null){
result.Append(<xsl:value-of select="@name"/>.ToString( "t"));
}
</xsl:when>
<xsl:when test="@required = 'true' and (@type = 'integer' or @type = 'real' or @type = 'boolean' or @type = 'money')">
<!-- can't be null because we will have generated a non-nullable type -->
result.Append(<xsl:value-of select="@name"/>.ToString());
</xsl:when>
<xsl:otherwise>
if ( <xsl:value-of select="@name"/> != null){
result.Append(<xsl:value-of select="@name"/>);
}
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
<xsl:when test="position() = last()"/>
<xsl:otherwise>
result.Append( ",");
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
result.AppendFormat( "<xsl:value-of select="@name"/>#{0}", KeyString);
</xsl:otherwise>
</xsl:choose>
return result.ToString();
}
}
/// &lt;summary&gt;
/// If I should not be deleted, return a message explaining why I should not be deleted; else null.
/// &lt;/summary&gt;
/// &lt;returns&gt;a message explaining why I should not be deleted; else null&lt;/returns&gt;
public override string NoDeleteReason {
get {
string result = null;
<xsl:if test="adl:property[@type='list']|adl:property[@type='link']">
StringBuilder bob = new StringBuilder();
<!-- TODO: we ought to start worrying about internationalisation NOW, not later! -->
<xsl:for-each select="adl:property[@type='list']|adl:property[@type='link']">
<xsl:choose>
<xsl:when test="@cascade='manual'"/>
<xsl:when test="@cascade='all'"/>
<xsl:when test="@cascade='all-delete-orphan'"/>
<xsl:when test="@cascade='delete'"/>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
if ( <xsl:value-of select="concat( ' _', @name)"/> != null &amp;&amp; <xsl:value-of select="concat( ' _', @name)"/>.Count > 0) {
bob.AppendFormat("Cannot delete this <xsl:value-of select="../@name"/> as it has {0} dependent <xsl:value-of select="@name"/>; ", <xsl:value-of select="concat( ' _', @name)"/>.Count);
}
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
if (bob.Length > 0) {
result = bob.ToString();
}
</xsl:if>
return result;
}
}
<!-- 'descendant' to catch properties inside keys as well as properties which are direct children -->
<xsl:apply-templates select="descendant::adl:property"/>
}
}
/* ---- [ cut here: next file 'junk'] ------------------------- */
</xsl:template>
<xsl:template match="adl:property[@concrete='false']">
<!-- generate nothing for non-concrete properties -->
/* NOTE: property '<xsl:value-of select="@name"/>' is marked as being abstract; it must
* be supported by manually maintained code */
</xsl:template>
<xsl:template match="adl:property">
// auto generating iv/property pair for slot with name <xsl:value-of select="@name"/>
<xsl:apply-templates select="help"/>
<xsl:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="csharp-type">
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="nullable-decoration">
<xsl:choose>
<xsl:when test="@required='true'"/>
<!-- when required is 'true' null is not permitted anyway; otherwise... -->
<xsl:when test="@type='message'"/>
<xsl:when test="$base-type='entity'"/>
<xsl:when test="$base-type='string'"/>
<xsl:when test="$base-type='text'"/>
<!-- entities and strings are always nullable, don't need decoration -->
<xsl:when test="$base-type='list'"/>
<xsl:when test="$base-type='link'"/>
<!-- things which are collections are not nullable -->
<xsl:otherwise>?</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="initialiser">
<xsl:choose>
<xsl:when test="@default">
<xsl:choose>
<xsl:when test="$csharp-type = 'String'">
= "<xsl:value-of select="@default"/>"
</xsl:when>
<xsl:otherwise>
= <xsl:value-of select="@default"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="normalize-space( $nullable-decoration) = '?'"> = null</xsl:when>
<xsl:when test="$base-type = 'Boolean'"> = false</xsl:when>
<xsl:when test="$base-type = 'int'"> = 0</xsl:when>
<xsl:when test="$csharp-type = 'Decimal'"> = 0.0M</xsl:when>
<xsl:when test="$base-type = 'real'"> = 0.0</xsl:when>
<xsl:when test="$base-type='String'"> = null</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="validationpattern">
<xsl:choose>
<xsl:when test="@type='defined'">
<xsl:variable name="definition">
<xsl:value-of select="@typedef"/>
</xsl:variable>
<xsl:value-of select="//adl:typedef[@name=$definition]/@pattern"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:if test="string-length( $validationpattern) &gt; 0">
private Regex <xsl:value-of select="@name"/>Validator = new Regex( "<xsl:value-of select="$validationpattern"/>");
</xsl:if>
<xsl:if test="$base-type = 'integer'">
<xsl:for-each select="adl:option">
<xsl:variable name="constname">
<xsl:call-template name="constname">
<xsl:with-param name="option" select="."/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>
</xsl:variable>
public const int <xsl:value-of select="$constname"/> =
<xsl:choose>
<xsl:when test="@value">
<xsl:value-of select="@value"/>
</xsl:when>
<xsl:when test="adl:prompt[@locale='default']/@prompt">
<xsl:value-of select="adl:prompt[@locale='default']/@prompt"/>
</xsl:when>
<xsl:when test="adl:prompt[@locale=$locale]/@prompt">
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: Cannot infer a value for option
</xsl:message>
</xsl:otherwise>
</xsl:choose>;
</xsl:for-each>
</xsl:if>
private <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/> <xsl:value-of select="concat( ' _', @name)"/> <xsl:value-of select="normalize-space( $initialiser)"/>;
/// &lt;summary&gt;
<xsl:choose>
<xsl:when test="adl:documentation">/// <xsl:value-of select="normalize-space(adl:documentation)"/></xsl:when>
<xsl:otherwise>/// Auto generated property for field <xsl:value-of select="@name"/></xsl:otherwise>
</xsl:choose>
/// <xsl:value-of select="normalize-space( help[@locale=$locale])"/>
/// &lt;/summary&gt;
<xsl:choose>
<xsl:when test="parent::adl:key">[PrimaryKey]</xsl:when>
<xsl:when test="$base-type='text'">[Property(ColumnType="StringClob")]</xsl:when>
<xsl:when test="$base-type='list'">
<xsl:choose>
<xsl:when test="@cascade='all'">
[HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.All)]
</xsl:when>
<xsl:when test="@cascade='all-delete-orphan'">
[HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.AllDeleteOrphan)]
</xsl:when>
<xsl:when test="@cascade='delete'">[HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.Delete)]</xsl:when>
<xsl:when test="@cascade='save-update'">[HasMany(Inverse=true, Cascade=ManyRelationCascadeEnum.SaveUpdate)]</xsl:when>
<xsl:otherwise>[HasMany]</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$base-type='entity'">[BelongsTo(<xsl:value-of select="@entity"/>)]</xsl:when>
<xsl:otherwise>[Property]</xsl:otherwise>
</xsl:choose>
<xsl:if test="@distinct = 'user' or @distinct = 'all'">[IsUserDistinct()]</xsl:if>
public virtual <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/>
{
get {
<xsl:if test="$base-type='list'">
if ( <xsl:value-of select="concat( ' _', @name)"/> == null) {
<xsl:value-of select="concat( '_', @name)"/> = new List&lt;<xsl:value-of select="@entity"/>&gt;();
}
</xsl:if>
return <xsl:value-of select="concat( ' _', @name)"/>;
}
set {
<xsl:if test="@required='true'">
<!-- If we could generate a non-nullable type we have done so; otherwise,
must catch null -->
<xsl:choose>
<xsl:when test="@type='integer'"/>
<xsl:when test="@type='real'"/>
<xsl:when test="@type='money'">
<!-- not quite certain of that - check! -->
</xsl:when>
<xsl:when test="@type='boolean'"/>
<xsl:otherwise>
if ( value == null)
{
throw new DataRequiredException( <xsl:choose>
<xsl:when test="ifmissing[@locale=$locale]">
<xsl:apply-templates select="ifmissing"/>
</xsl:when>
<xsl:otherwise>
"The value for <xsl:value-of select="@name"/> may not be set to null"
</xsl:otherwise>
</xsl:choose>
);
}
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:if test="@type='defined'">
<xsl:variable name="definition">
<xsl:value-of select="@typedef"/>
</xsl:variable>
<xsl:variable name="maximum">
<xsl:value-of select="//adl:typedef[@name=$definition]/@maximum"/>
</xsl:variable>
<xsl:variable name="minimum">
<xsl:value-of select="//adl:typedef[@name=$definition]/@minimum"/>
</xsl:variable>
<xsl:if test="string-length( $maximum) &gt; 0">
if ( value &gt; <xsl:value-of select="$maximum"/>)
{
throw new DataRangeException( "The maximum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$maximum"/>");
}
</xsl:if>
<xsl:if test="string-length( $minimum) &gt; 0">
if ( value &lt; <xsl:value-of select="$minimum"/>)
{
throw new DataRangeException( "The minimum permitted value for <xsl:value-of select="@name"/> is <xsl:value-of select="$minimum"/>");
}
</xsl:if>
<xsl:if test="string-length( $validationpattern) &gt; 0">
if ( value != null &amp;&amp; ! <xsl:value-of select="@name"/>Validator.IsMatch( value))
{
throw new DataFormatException( string.Format( "The value supplied ({0}) does not match the format required by <xsl:value-of select="@name"/>", value));
}
</xsl:if>
</xsl:if>
<xsl:if test="adl:option">
<xsl:choose>
<xsl:when test="$base-type = 'integer'">
switch ( value ) {
<xsl:for-each select="adl:option">
case <xsl:call-template name="constname">
<xsl:with-param name="option" select="."/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>:
</xsl:for-each>
break;
default:
throw new DataRangeException( string.Format( "The value supplied ({0}) is not an acceptable value for <xsl:value-of select="@name"/>", value));
}
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="@size and $csharp-type='String'">
if ( value != null &amp;&amp; value.Length > <xsl:value-of select="@size"/>)
{
value = value.Substring( 0, <xsl:value-of select="@size"/>);
}
</xsl:if>
<xsl:value-of select="concat( ' _', @name)"/> = value;
}
}
<xsl:if test="parent::adl:key and @type='entity'">
/// &lt;summary&gt;
/// auto generated primitive value for key property of type entity (experimental)
/// &lt;/summary&gt;
<xsl:variable name="csharp-base-type">
<xsl:call-template name="csharp-base-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
private <xsl:value-of select="concat( $csharp-base-type, ' _', @name, '_Value')"/> <xsl:choose>
<xsl:when test="$csharp-base-type = 'Boolean'"> = false</xsl:when>
<xsl:when test="$csharp-base-type = 'int'"> = 0</xsl:when>
<xsl:when test="$csharp-base-type = 'Decimal'"> = 0.0M</xsl:when>
<xsl:when test="$csharp-base-type = 'real'"> = 0.0</xsl:when>
<xsl:when test="$csharp-base-type='String'"> = null</xsl:when>
<xsl:otherwise>
[unknown? <xsl:value-of select="$csharp-base-type"/>]
</xsl:otherwise>
</xsl:choose>;
/// &lt;summary&gt;
/// auto generated primitive value getter/setter for key property of type entity (experimental)
/// &lt;/summary&gt;
public virtual <xsl:value-of select="concat( $csharp-base-type, ' ', @name, '_Value')"/> {
get { return <xsl:value-of select="concat( '_', @name, '_Value')"/>; }
set { <xsl:value-of select="concat( '_', @name, '_Value')"/> = value; }
}
</xsl:if>
</xsl:template>
<xsl:template match="adl:help">
<xsl:if test="@locale=$locale">
<!-- might conceivably be more than one line -->
<xsl:text>
/* </xsl:text><xsl:apply-templates/> */
</xsl:if>
</xsl:template>
<xsl:template match="ifmissing">
<xsl:if test="@locale=$locale">
"<xsl:value-of select="normalize-space(.)"/>"
</xsl:if>
</xsl:template>
<xsl:template match="adl:documentation">
/// <xsl:apply-templates/>
</xsl:template>
<xsl:template name="initialise-messages">
<!-- each IV of type message needs to be initialised -->
<xsl:for-each select="adl:property[@type='message']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<xsl:value-of select="concat( ' _', @name)"/> = new Message();
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<xsl:template name="initialise-lists">
<!-- initialise all concrete lists and links -->
<xsl:for-each select="adl:property[@type='list' or @type='link']">
<xsl:choose>
<xsl:when test="@concrete='false'"/>
<xsl:otherwise>
<xsl:value-of select="concat( ' _', @name)"/> = new List&lt;<xsl:value-of select="@entity"/>&gt;();
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
<!-- produce a name for a constant value from an option entity -->
<xsl:template name="constname">
<xsl:param name="option"/>
<xsl:param name="locale"/>
<xsl:variable name="unnormalisedname">
<xsl:choose>
<xsl:when test="$option/adl:prompt[@locale='default']">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/adl:prompt[@locale='default']/@prompt, '_value')"/>
</xsl:when>
<xsl:when test="$option/adl:prompt[@locale=$locale]">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/adl:prompt[@locale=$locale]/@prompt, '_value')"/>
</xsl:when>
<xsl:when test="$option/@value">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/@value, '_value')"/>
</xsl:when>
<xsl:otherwise>
<!-- this one's dodgy but shouldn't be hit often (perhaps never) -->
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
position(), '_value')"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="translate($unnormalisedname,
$notpermittedinconstantname, $permittedinconstantname)"/>
</xsl:template>
<xsl:template name="csharp-base-type">
<xsl:param name="property"/>
<xsl:param name="entityns"/>
<xsl:choose>
<xsl:when test="$property/@type = 'entity'">
<xsl:variable name="entityname" select="$property/@entity"/>
<xsl:choose>
<xsl:when test="//adl:entity[@name=$entityname]/adl:key/adl:property">
<!-- recurse... -->
<xsl:call-template name="csharp-base-type">
<xsl:with-param name="property"
select="//adl:entity[@name=$entityname]/adl:key/adl:property[position()=1]"/>
<xsl:with-param name="entityns" select="$entityns"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: could not find C# base type of property <xsl:value-of select="$property/@name"/>
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="$property"/>
<xsl:with-param name="entityns" select="$entityns"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- return the C# type of the property which is passed as a parameter -->
<xsl:template name="csharp-type">
<xsl:param name="property"/>
<xsl:param name="entityns"/>
<xsl:variable name="base-type">
<xsl:call-template name="base-type">
<xsl:with-param name="property" select="$property"/>
</xsl:call-template>
</xsl:variable>
<xsl:choose>
<xsl:when test="$property/@type = 'message'">Message</xsl:when>
<xsl:when test="$base-type = 'link'">
IList&lt;<xsl:value-of select="@entity"/>&gt;
</xsl:when>
<xsl:when test="$base-type = 'list'">
IList&lt;<xsl:value-of select="@entity"/>&gt;
</xsl:when>
<xsl:when test="$base-type = 'date'">DateTime</xsl:when>
<xsl:when test="$base-type = 'time'">DateTime</xsl:when>
<xsl:when test="$base-type = 'string'">String</xsl:when>
<xsl:when test="$base-type = 'text'">String</xsl:when>
<xsl:when test="$base-type = 'boolean'">Boolean</xsl:when>
<xsl:when test="$base-type = 'timestamp'">DateTime</xsl:when>
<xsl:when test="$base-type = 'integer'">int</xsl:when>
<xsl:when test="$base-type = 'real'">double</xsl:when>
<xsl:when test="$base-type = 'money'">Decimal</xsl:when>
<xsl:when test="$base-type = 'entity'">
<xsl:choose>
<xsl:when test="$entityns">
<xsl:value-of select="concat( $entityns, '.', $property/@entity)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$property/@entity"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>[unknown?]</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>

View file

@ -20,8 +20,8 @@
explicitly state the permission, even if it is 'none'. explicitly state the permission, even if it is 'none'.
$Author: sb $ $Author: sb $
$Revision: 1.3 $ $Revision: 1.4 $
$Date: 2008-07-15 15:20:53 $ $Date: 2008-10-02 10:43:46 $
--> -->
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
@ -63,6 +63,7 @@
<xsl:value-of select="@revision"/> <xsl:value-of select="@revision"/>
</xsl:attribute> </xsl:attribute>
</xsl:if> </xsl:if>
<xsl:apply-templates select="@*"/>
<xsl:comment> <xsl:comment>
*************************************************************************** ***************************************************************************
@ -73,11 +74,11 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT * THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED. * BE MANUALLY EDITED.
* *
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.3 $', 12)"/> * Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.4 $', 12)"/>
* *
*************************************************************************** ***************************************************************************
</xsl:comment> </xsl:comment>
<xsl:apply-templates select="@* | node()"/> <xsl:apply-templates select="*"/>
</xsl:copy> </xsl:copy>
</xsl:template> </xsl:template>

View file

@ -9,8 +9,8 @@
Transform ADL into (partial) controller classes Transform ADL into (partial) controller classes
$Author: sb $ $Author: sb $
$Revision: 1.16 $ $Revision: 1.17 $
$Date: 2008-08-22 17:14:41 $ $Date: 2008-10-02 10:43:42 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -67,7 +67,7 @@
// //
// Automatically generated abstract super class for controllers for the // Automatically generated abstract super class for controllers for the
// <xsl:value-of select="/adl:application/@name"/> application; generated using // <xsl:value-of select="/adl:application/@name"/> application; generated using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
// //
// <xsl:value-of select="/adl:application/@revision"/> // <xsl:value-of select="/adl:application/@revision"/>
// //
@ -135,7 +135,7 @@
// //
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s // Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
// Automatically generated from application description using // Automatically generated from application description using
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.16 $', 10)"/> // adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
// //
// This file is automatically generated; DO NOT EDIT IT. // This file is automatically generated; DO NOT EDIT IT.
// //

View file

@ -53,7 +53,7 @@
</a> </a>
</dt> </dt>
<dd> <dd>
<xsl:apply-templates select="adl:documentation"/> <xsl:value-of select="adl:documentation"/>
</dd> </dd>
</xsl:for-each> </xsl:for-each>
</dl> </dl>
@ -132,7 +132,15 @@
</a> </a>
</xsl:when> </xsl:when>
<xsl:when test="@type = 'list'"> <xsl:when test="@type = 'list'">
(one to many) of entities of type <a> <xsl:choose>
<xsl:when test="@required='true'">
(one to one-or-many)
</xsl:when>
<xsl:otherwise>
(one to zero-or-many)
</xsl:otherwise>
</xsl:choose>
of entities of type <a>
<xsl:attribute name="href"> <xsl:attribute name="href">
<xsl:value-of select="concat( '#entity-', @entity)"/> <xsl:value-of select="concat( '#entity-', @entity)"/>
</xsl:attribute> </xsl:attribute>
@ -148,7 +156,7 @@
<xsl:value-of select="/adl:application/adl:definition[@name=$definition]/@type"/> <xsl:value-of select="/adl:application/adl:definition[@name=$definition]/@type"/>
</xsl:variable> </xsl:variable>
<xsl:choose> <xsl:choose>
<xsl:when test="$defined-type = 'string'"> <xsl:when test="$defined-type = 'string'">
String matching String matching
"<xsl:value-of select="/adl:application/adl:definition[@name=$definition]/@pattern"/>" "<xsl:value-of select="/adl:application/adl:definition[@name=$definition]/@pattern"/>"
</xsl:when> </xsl:when>
@ -294,10 +302,62 @@
<xsl:template match="adl:documentation"> <xsl:template match="adl:documentation">
<div xmlns="http://www.w3.org/1999/xhtml" class="documentation"> <div xmlns="http://www.w3.org/1999/xhtml" class="documentation">
<xsl:apply-templates /> <xsl:value-of select="."/>
<xsl:if test="adl:reference">
<h4>See also</h4>
<ul>
<xsl:apply-templates select="adl:reference"/>
</ul>
</xsl:if>
</div> </div>
</xsl:template> </xsl:template>
<xsl:template match="adl:reference">
<xsl:variable name="abbr" select="@abbr"/>
<xsl:variable name="specification" select="/adl:application/adl:specification[@abbr=$abbr]"/>
<li xmlns="http://www.w3.org/1999/xhtml">
<xsl:choose>
<xsl:when test="@entity">
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('#',@entity)"/>
</xsl:attribute>
<xsl:value-of select="@entity"/>
<xsl:if test="@property">
: <xsl:value-of select="@property"/>
</xsl:if>
</a>
</xsl:when>
<xsl:when test="$specification/@url">
<a xmlns="http://www.w3.org/1999/xhtml">
<xsl:attribute name="href">
<xsl:choose>
<xsl:when test="@section">
<xsl:value-of select="concat( $specification/@url, '#', @section)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$specification/@url"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:value-of select="$specification/@name"/>:
<xsl:if test="@section">
<xsl:value-of select="@section"/>:
</xsl:if>
</a>
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$specification/@name"/>:
<xsl:if test="@section">
<xsl:value-of select="@section"/>:
</xsl:if>
<xsl:apply-templates/>
</xsl:otherwise>
</xsl:choose>
</li>
</xsl:template>
<xsl:template match="adl:form"> <xsl:template match="adl:form">
<div xmlns="http://www.w3.org/1999/xhtml"> <div xmlns="http://www.w3.org/1999/xhtml">
<h3 xmlns="http://www.w3.org/1999/xhtml"> <h3 xmlns="http://www.w3.org/1999/xhtml">

View file

@ -5,11 +5,11 @@
(c) 2007 Cygnet Solutions Ltd (c) 2007 Cygnet Solutions Ltd
Transform ADL into entity classes Transform ADL into C# entity classes
$Author: sb $ $Author: sb $
$Revision: 1.12 $ $Revision: 1.13 $
$Date: 2008-08-26 11:10:57 $ $Date: 2008-10-02 10:43:42 $
--> -->
<!-- WARNING WARNING WARNING: Do NOT reformat this file! <!-- WARNING WARNING WARNING: Do NOT reformat this file!
@ -30,7 +30,7 @@
client's locale. However, there may still need to be a concept of a client's locale. However, there may still need to be a concept of a
'default locale', for when we don't have messages which suit the 'default locale', for when we don't have messages which suit the
client's locale --> client's locale -->
<xsl:param name="locale" select="en-UK"/> <xsl:param name="locale" select="en-GB"/>
<!-- The C# namespace within which I shall generate controllers --> <!-- The C# namespace within which I shall generate controllers -->
<xsl:param name="controllerns" select="Unset"/> <xsl:param name="controllerns" select="Unset"/>
@ -40,7 +40,12 @@
<!-- the name and version of the product being built --> <!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/> <xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- strings used in normalising names for constants.
NOTE NOTE NOTE:
this deliberately converts space and punctuation to underscore -->
<xsl:variable name="notpermittedinconstantname">abcdefghijklmnopqrstuvwxyz .,;:?/()</xsl:variable>
<xsl:variable name="permittedinconstantname">ABCDEFGHIJKLMNOPQRSTUVWXYZ_________</xsl:variable>
<xsl:template match="adl:application"> <xsl:template match="adl:application">
<xsl:apply-templates select="adl:entity"/> <xsl:apply-templates select="adl:entity"/>
@ -61,7 +66,7 @@
// (c)2007 Cygnet Solutions Ltd // (c)2007 Cygnet Solutions Ltd
// //
// Automatically generated from application description using // Automatically generated from application description using
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.12 $', 10)"/> // adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>
// //
// <xsl:value-of select="/adl:application/@revision"/> // <xsl:value-of select="/adl:application/@revision"/>
// //
@ -77,6 +82,8 @@
using Cygnet.Exceptions; using Cygnet.Exceptions;
using Cygnet.Entities; using Cygnet.Entities;
using Iesi.Collections.Generic; using Iesi.Collections.Generic;
using NHibernate;
using NHibernate.Classic;
namespace <xsl:value-of select="$entityns"/> namespace <xsl:value-of select="$entityns"/>
{ {
@ -85,7 +92,7 @@
/// &lt;/summary&gt; /// &lt;/summary&gt;
/// &lt;remarks&gt; /// &lt;remarks&gt;
/// Automatically generated from description of entity <xsl:value-of select="@name"/> /// Automatically generated from description of entity <xsl:value-of select="@name"/>
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.12 $', 10)"/>. /// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.13 $', 10)"/>.
/// Note that manually maintained parts of this class may be defined in /// Note that manually maintained parts of this class may be defined in
/// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v. /// a separate file called <xsl:value-of select="@name"/>.manual.cs, q.v.
/// ///
@ -153,7 +160,7 @@
return result.ToString(); return result.ToString();
} }
} }
/// &lt;summary&gt; /// &lt;summary&gt;
/// True if I have not yet been persisted to the database, else false. /// True if I have not yet been persisted to the database, else false.
/// NOTE: This code is experimental and may change! /// NOTE: This code is experimental and may change!
@ -162,24 +169,24 @@
get { get {
Boolean result = false; Boolean result = false;
<xsl:for-each select="descendant::adl:property[adl:generator]"> <xsl:for-each select="descendant::adl:property[adl:generator]">
<xsl:choose> <xsl:choose>
<xsl:when test="@type='integer'"> <xsl:when test="@type='integer'">
if ( <xsl:value-of select="@name"/> == 0) { if ( <xsl:value-of select="@name"/> == 0) {
result = true; result = true;
} }
</xsl:when> </xsl:when>
<xsl:when test="@type='string'"> <xsl:when test="@type='string'">
if ( String.IsNullOrEmpty( <xsl:value-of select="@name"/>)) { if ( String.IsNullOrEmpty( <xsl:value-of select="@name"/>)) {
result = true; result = true;
} }
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
/* TODO: ADL does not yet correctly generate IsNew for /* TODO: ADL does not yet correctly generate IsNew for
* properties of type <xsl:value-of select="@type"/> */ * properties of type <xsl:value-of select="@type"/> */
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:for-each> </xsl:for-each>
return result; return result;
} }
} }
@ -278,6 +285,28 @@
return result; return result;
} }
} }
/// &lt;summary&gt;
/// Should I permit myself to be deleted? If I have a valid NoDeleteReason then no. Otherwise
/// I should remove my backlinks to entities which list me in lists which have 'inverse="true"'
/// &lt;/summary&gt;
/// &lt;returns&gt;a veto if I should not be deleted; else no veto&lt;/returns&gt;
public override LifecycleVeto OnDelete(ISession hibernator) {
string ndr = NoDeleteReason;
LifecycleVeto result = LifecycleVeto.NoVeto;
if ( ndr != null) {
result = LifecycleVeto.Veto;
} else {
_indeletion = true;
<xsl:for-each select="adl:property[ @type='entity']">
<!-- if the property is not a magic backlink, nulling it before deleting does no harm.
if it is a magic backlink, nulling it will(?) clear the reference at the far end. -->
<xsl:value-of select="@name"/> = null;
</xsl:for-each>
}
return result;
}
<!-- 'descendant' to catch properties inside keys as well as properties which are direct children --> <!-- 'descendant' to catch properties inside keys as well as properties which are direct children -->
<xsl:apply-templates select="descendant::adl:property"/> <xsl:apply-templates select="descendant::adl:property"/>
} }
@ -338,7 +367,16 @@
<xsl:when test="$base-type = 'int'"> = 0</xsl:when> <xsl:when test="$base-type = 'int'"> = 0</xsl:when>
<xsl:when test="$csharp-type = 'Decimal'"> = 0.0M</xsl:when> <xsl:when test="$csharp-type = 'Decimal'"> = 0.0M</xsl:when>
<xsl:when test="$base-type = 'real'"> = 0.0</xsl:when> <xsl:when test="$base-type = 'real'"> = 0.0</xsl:when>
<xsl:when test="$base-type='String'"> = null</xsl:when> <xsl:when test="$csharp-type = 'String'">
<xsl:choose>
<xsl:when test="@required='true'">
= ""
</xsl:when>
<xsl:otherwise>
= null
</xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
@ -356,6 +394,34 @@
private Regex <xsl:value-of select="@name"/>Validator = new Regex( "<xsl:value-of select="$validationpattern"/>"); private Regex <xsl:value-of select="@name"/>Validator = new Regex( "<xsl:value-of select="$validationpattern"/>");
</xsl:if> </xsl:if>
<xsl:if test="$base-type = 'integer'">
<xsl:for-each select="adl:option">
<xsl:variable name="constname">
<xsl:call-template name="constname">
<xsl:with-param name="option" select="."/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>
</xsl:variable>
public const int <xsl:value-of select="$constname"/> =
<xsl:choose>
<xsl:when test="@value">
<xsl:value-of select="@value"/>
</xsl:when>
<xsl:when test="adl:prompt[@locale='default']/@prompt">
<xsl:value-of select="adl:prompt[@locale='default']/@prompt"/>
</xsl:when>
<xsl:when test="adl:prompt[@locale=$locale]/@prompt">
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: Cannot infer a value for option
</xsl:message>
</xsl:otherwise>
</xsl:choose>;
</xsl:for-each>
</xsl:if>
private <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/> <xsl:value-of select="concat( ' _', @name)"/> <xsl:value-of select="normalize-space( $initialiser)"/>; private <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/> <xsl:value-of select="concat( ' _', @name)"/> <xsl:value-of select="normalize-space( $initialiser)"/>;
/// &lt;summary&gt; /// &lt;summary&gt;
@ -371,7 +437,18 @@
/// <xsl:value-of select="normalize-space( help[@locale=$locale])"/> /// <xsl:value-of select="normalize-space( help[@locale=$locale])"/>
</xsl:if> </xsl:if>
/// &lt;/summary&gt; /// &lt;/summary&gt;
<xsl:apply-templates select="adl:prompt"/>
<!-- TODO: this should get the size right if type = 'defined', but hasn't been tested -->
<xsl:if test="$base-type = 'string'">
<xsl:variable name="base-size">
<xsl:call-template name="base-size">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:variable>
[FieldWidth(<xsl:value-of select="$base-size"/>)]
</xsl:if>
<xsl:if test="@distinct = 'user' or @distinct = 'all'">[IsUserDistinct()]</xsl:if> <xsl:if test="@distinct = 'user' or @distinct = 'all'">[IsUserDistinct()]</xsl:if>
<xsl:if test="@type = 'money'">[Dimension( "money",Unit="<xsl:value-of select="ancestor::adl:application/@currency"/>")]</xsl:if>
public virtual <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/> public virtual <xsl:value-of select="normalize-space( $csharp-type)"/><xsl:value-of select="normalize-space( $nullable-decoration)"/><xsl:text> </xsl:text> <xsl:value-of select="@name"/>
{ {
get { get {
@ -395,7 +472,7 @@
</xsl:when> </xsl:when>
<xsl:when test="@type='boolean'"/> <xsl:when test="@type='boolean'"/>
<xsl:otherwise> <xsl:otherwise>
if ( value == null) if ( ! _indeletion &amp;&amp; value == null)
{ {
throw new DataRequiredException( <xsl:choose> throw new DataRequiredException( <xsl:choose>
<xsl:when test="ifmissing[@locale=$locale]"> <xsl:when test="ifmissing[@locale=$locale]">
@ -439,6 +516,52 @@
} }
</xsl:if> </xsl:if>
</xsl:if> </xsl:if>
<xsl:if test="adl:option">
<xsl:choose>
<xsl:when test="$base-type = 'integer'">
<xsl:choose>
<xsl:when test="@required='true'"/>
<xsl:otherwise>
if ( value != null){
</xsl:otherwise>
</xsl:choose>
switch ( value ) {
<xsl:for-each select="adl:option">
case <xsl:call-template name="constname">
<xsl:with-param name="option" select="."/>
<xsl:with-param name="locale" select="$locale"/>
</xsl:call-template>:
</xsl:for-each>
break;
default:
throw new DataRangeException( string.Format( "The value supplied ({0}) is not an acceptable value for <xsl:value-of select="@name"/>", value));
}
<xsl:choose>
<xsl:when test="@required='true'"/>
<xsl:otherwise>
} <!-- matches brace on 'if ( value != null) {' above -->
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$base-type = 'string'">
bool acceptable = false;
<xsl:choose>
<xsl:when test="@required='true'"/>
<xsl:otherwise>
if ( value == null) { acceptable = true; } else
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="adl:option">
if ( "<xsl:value-of select="@value"/>".Equals( value)) { acceptable = true; }
<xsl:if test="position() != last()">else</xsl:if>
</xsl:for-each>
if ( ! acceptable) {
throw new DataRangeException( string.Format( "The value supplied ('{0}') is not an acceptable value for <xsl:value-of select="@name"/>", value));
}
</xsl:when>
</xsl:choose>
</xsl:if>
<xsl:if test="@size and $csharp-type='String'"> <xsl:if test="@size and $csharp-type='String'">
if ( value != null &amp;&amp; value.Length > <xsl:value-of select="@size"/>) if ( value != null &amp;&amp; value.Length > <xsl:value-of select="@size"/>)
{ {
@ -488,6 +611,10 @@
</xsl:if> </xsl:if>
</xsl:template> </xsl:template>
<xsl:template match="adl:prompt">
[LocalisedDisplayName( "<xsl:value-of select="@prompt"/>", Locale="<xsl:value-of select="@locale"/>")]
</xsl:template>
<xsl:template match="ifmissing"> <xsl:template match="ifmissing">
<xsl:if test="@locale=$locale"> <xsl:if test="@locale=$locale">
"<xsl:value-of select="normalize-space(.)"/>" "<xsl:value-of select="normalize-space(.)"/>"
@ -518,4 +645,31 @@
</xsl:for-each> </xsl:for-each>
</xsl:template> </xsl:template>
<!-- produce a name for a constant value from an option entity -->
<xsl:template name="constname">
<xsl:param name="option"/>
<xsl:param name="locale"/>
<xsl:variable name="unnormalisedname">
<xsl:choose>
<xsl:when test="$option/adl:prompt[@locale='default']">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/adl:prompt[@locale='default']/@prompt, '_value')"/>
</xsl:when>
<xsl:when test="$option/adl:prompt[@locale=$locale]">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/adl:prompt[@locale=$locale]/@prompt, '_value')"/>
</xsl:when>
<xsl:when test="$option/@value">
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
$option/@value, '_value')"/>
</xsl:when>
<xsl:otherwise>
<!-- this one's dodgy but shouldn't be hit often (perhaps never) -->
<xsl:value-of select="concat( $option/ancestor::adl:property/@name, '_',
position(), '_value')"/></xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="translate($unnormalisedname,
$notpermittedinconstantname, $permittedinconstantname)"/>
</xsl:template>
</xsl:stylesheet> </xsl:stylesheet>

View file

@ -12,15 +12,28 @@
Transform ADL to Hibernate Transform ADL to Hibernate
$Author: sb $ $Author: sb $
$Revision: 1.5 $ $Revision: 1.6 $
--> -->
<xsl:param name="namespace"/> <xsl:param name="namespace"/>
<xsl:param name="assembly"/> <xsl:param name="assembly"/>
<xsl:param name="database"/> <xsl:param name="database"/>
<!-- whether or not we want lazy initialisation of lists. Lazy initialisation
is economic of memory and of startup time, and works well in things which are
essentially atomic like Web transactions; but can lead to gnarly bugs.
Values: 'true' (default) or 'false' - anything else will result in an error -->
<xsl:param name="lazy" select="'true'"/>
<!-- the name and version of the product being built --> <!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/> <xsl:param name="product-version" select="'Application Description Language Framework'"/>
<!-- the convention to use for fieldnames in link tables:
Name - the name of the foreign key is the same as the name of the table linked to
NameId - the name of the foreign key is the same as the name of the table linked to, followed by 'Id'
Name_Id - the name of the foreign key is the same as the name of the table linked to, followed by '_Id'
Name_Link - the name of the foreign key is the same as the name of the table linked to, followed by '_Link'
-->
<xsl:param name="linktable-field-name-convention" select="Name"/>
<xsl:output indent="no" method="xml" encoding="UTF-8"/> <xsl:output indent="no" method="xml" encoding="UTF-8"/>
<!-- NOTE! indent="no" because hibernate falls over if there is whitespace inside <!-- NOTE! indent="no" because hibernate falls over if there is whitespace inside
a 'key' or 'one-to-many' element, and the printer used by the NAnt 'style' task a 'key' or 'one-to-many' element, and the printer used by the NAnt 'style' task
@ -125,7 +138,7 @@
* *
* <xsl:value-of select="@revision"/> * <xsl:value-of select="@revision"/>
* *
* Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.5 $', 12)"/> * Generated using adl2hibernate.xslt revision <xsl:value-of select="substring('$Revision: 1.6 $', 12)"/>
* *
*************************************************************************** ***************************************************************************
</xsl:comment> </xsl:comment>
@ -415,6 +428,9 @@
<xsl:attribute name="name"> <xsl:attribute name="name">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="lazy">
<xsl:value-of select="$lazy"/>
</xsl:attribute>
<xsl:attribute name="inverse"> <xsl:attribute name="inverse">
<!-- true if the other end of the link is described in the ADL (which it normally will be) --> <!-- true if the other end of the link is described in the ADL (which it normally will be) -->
<xsl:choose> <xsl:choose>
@ -422,20 +438,14 @@
<xsl:otherwise>false</xsl:otherwise> <xsl:otherwise>false</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
<xsl:apply-templates select="adl:documentation"/> <xsl:attribute name="cascade">
<!-- careful with reformatting here: <xsl:choose>
'The element cannot contain white space. Content model is empty.' --> <xsl:when test="@cascade">
<key> <xsl:value-of select="@cascade"/>
<xsl:attribute name="column"> </xsl:when>
<!-- this is the name of the farside foreign key field which points to me --> <xsl:otherwise>all</xsl:otherwise>
<xsl:value-of select="$farkey"/> </xsl:choose>
</xsl:attribute> </xsl:attribute>
</key>
<one-to-many>
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
</xsl:attribute>
</one-to-many>
<xsl:choose> <xsl:choose>
<xsl:when test="@cascade='manual'"/> <xsl:when test="@cascade='manual'"/>
<xsl:when test="@cascade"> <xsl:when test="@cascade">
@ -444,6 +454,22 @@
</xsl:attribute> </xsl:attribute>
</xsl:when> </xsl:when>
</xsl:choose> </xsl:choose>
<xsl:apply-templates select="adl:documentation"/>
<!-- careful with reformatting here:
'The element cannot contain white space. Content model is empty.' -->
<key>
<xsl:attribute name="column">
<!-- this is the name of the farside foreign key field which points to me -->
<xsl:call-template name="maybe-escape-keyword">
<xsl:with-param name="unescaped" select="$farkey"/>
</xsl:call-template>
</xsl:attribute>
</key>
<one-to-many>
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
</xsl:attribute>
</one-to-many>
</set> </set>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
@ -475,23 +501,53 @@
<xsl:attribute name="name"> <xsl:attribute name="name">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="lazy">
<xsl:value-of select="$lazy"/>
</xsl:attribute>
<xsl:attribute name="table"> <xsl:attribute name="table">
<xsl:value-of select="$tablename"/> <xsl:value-of select="$tablename"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="cascade">
<xsl:choose>
<xsl:when test="@cascade">
<xsl:value-of select="@cascade"/>
</xsl:when>
<xsl:otherwise>all</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:apply-templates select="adl:documentation"/> <xsl:apply-templates select="adl:documentation"/>
<xsl:variable name="linksuffix">
<xsl:choose>
<xsl:when test="$linktable-field-name-convention = 'Name'"/>
<xsl:when test="$linktable-field-name-convention = 'NameId'">
<xsl:value-of select="'Id'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'Name_Id'">
<xsl:value-of select="'_Id'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'NameLink'">
<xsl:value-of select="'Link'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'Name_Link'">
<xsl:value-of select="'_Link'"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<key> <key>
<xsl:attribute name="column"> <xsl:attribute name="column">
<xsl:value-of select="concat( ../@name, 'Id')"/> <xsl:call-template name="maybe-escape-keyword">
<xsl:with-param name="unescaped" select="concat( ../@name, $linksuffix)"/>
</xsl:call-template>
</xsl:attribute> </xsl:attribute>
</key> </key>
<many-to-many> <many-to-many>
<xsl:attribute name="column"> <xsl:attribute name="column">
<xsl:choose> <xsl:choose>
<xsl:when test="../@name = @entity"> <xsl:when test="../@name = @entity">
<xsl:value-of select="concat( @entity, '_1Id')"/> <xsl:value-of select="concat( @entity, '_1', $linksuffix)"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="concat( @entity, 'Id')"/> <xsl:value-of select="concat( @entity, $linksuffix)"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
@ -527,25 +583,38 @@
</xsl:template> </xsl:template>
<xsl:template match="adl:documentation"> <xsl:template match="adl:documentation">
<xsl:comment> <xsl:choose>
<xsl:apply-templates/> <xsl:when test="ancestor::adl:documentation"/>
</xsl:comment> <xsl:otherwise>
<xsl:comment>
<xsl:apply-templates/>
</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:template> </xsl:template>
<!-- consistent, repeatable way of getting the column name for a given property --> <!-- consistent, repeatable way of getting the column name for a given property -->
<xsl:template name="property-column-name"> <xsl:template name="property-column-name">
<!-- a property element --> <!-- a property element -->
<xsl:param name="property"/> <xsl:param name="property"/>
<xsl:variable name="unescaped"> <xsl:call-template name="maybe-escape-keyword">
<xsl:choose> <xsl:with-param name="unescaped">
<xsl:when test="$property/@column"> <xsl:choose>
<xsl:value-of select="$property/@column"/> <xsl:when test="$property/@column">
</xsl:when> <xsl:value-of select="$property/@column"/>
<xsl:otherwise> </xsl:when>
<xsl:value-of select="$property/@name"/> <xsl:otherwise>
</xsl:otherwise> <xsl:value-of select="$property/@name"/>
</xsl:choose> </xsl:otherwise>
</xsl:variable> </xsl:choose>
</xsl:with-param>
</xsl:call-template>
</xsl:template>
<!-- if the string passed as a parameter is an SQL keyword, escape it with square brackets;
else return it as is.-->
<xsl:template name="maybe-escape-keyword">
<xsl:param name="unescaped"/>
<xsl:choose> <xsl:choose>
<xsl:when test="contains( $sqlkeywords, concat(' ', translate( $unescaped, $lcase, $ucase),' '))"> <xsl:when test="contains( $sqlkeywords, concat(' ', translate( $unescaped, $lcase, $ucase),' '))">
<xsl:value-of select="concat( '[', $unescaped, ']')"/> <xsl:value-of select="concat( '[', $unescaped, ']')"/>

View file

@ -12,7 +12,7 @@
Convert ADL to MS-SQL Convert ADL to MS-SQL
$Author: sb $ $Author: sb $
$Revision: 1.12 $ $Revision: 1.13 $
--> -->
<xsl:output indent="no" encoding="UTF-8" method="text"/> <xsl:output indent="no" encoding="UTF-8" method="text"/>
@ -26,6 +26,15 @@
Name_Id - the name of the auto generated primary key is the name of the entity followed by '_Id' Name_Id - the name of the auto generated primary key is the name of the entity followed by '_Id'
--> -->
<xsl:param name="abstract-key-name-convention" select="Id"/> <xsl:param name="abstract-key-name-convention" select="Id"/>
<!-- the convention to use for fieldnames in link tables:
Name - the name of the foreign key is the same as the name of the table linked to
NameId - the name of the foreign key is the same as the name of the table linked to, followed by 'Id'
Name_Id - the name of the foreign key is the same as the name of the table linked to, followed by '_Id'
Name_Link - the name of the foreign key is the same as the name of the table linked to, followed by '_Link'
-->
<xsl:param name="linktable-field-name-convention" select="Name"/>
<xsl:param name="database"/> <xsl:param name="database"/>
<!-- the name and version of the product being built --> <!-- the name and version of the product being built -->
<xsl:param name="product-version" select="'Application Description Language Framework'"/> <xsl:param name="product-version" select="'Application Description Language Framework'"/>
@ -103,7 +112,7 @@
-- <xsl:value-of select="$product-version"/> -- <xsl:value-of select="$product-version"/>
-- --
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@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.12 $', 12)"/> -- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.13 $', 12)"/>
-- THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT IT. -- THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT IT.
-- --
-- <xsl:value-of select="@revision"/> -- <xsl:value-of select="@revision"/>
@ -414,9 +423,25 @@
</xsl:variable> </xsl:variable>
<xsl:variable name="farentityname" select="@entity"/> <xsl:variable name="farentityname" select="@entity"/>
<xsl:variable name="farentity" select="//adl:entity[@name=$farentityname]"/> <xsl:variable name="farentity" select="//adl:entity[@name=$farentityname]"/>
<xsl:variable name="linksuffix">
<xsl:choose>
<xsl:when test="$linktable-field-name-convention = 'Name'"/>
<xsl:when test="$linktable-field-name-convention = 'NameId'">
<xsl:value-of select="'Id'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'Name_Id'">
<xsl:value-of select="'_Id'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'NameLink'">
<xsl:value-of select="'Link'"/>
</xsl:when>
<xsl:when test="$linktable-field-name-convention = 'Name_Link'">
<xsl:value-of select="'_Link'"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="myresponsibility"> <xsl:variable name="myresponsibility">
<xsl:choose> <xsl:choose>
<!-- if we could use the compare( string, string) function this would be a lot simpler, but <!-- if we could use the compare( string, string) function this would be a lot simpler, but
unfortunately that's in XSL 2.0, and neither NAnt nor Visual Studio can manage that --> unfortunately that's in XSL 2.0, and neither NAnt nor Visual Studio can manage that -->
@ -464,10 +489,10 @@
------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------
CREATE TABLE "<xsl:value-of select="$linktablename"/>" CREATE TABLE "<xsl:value-of select="$linktablename"/>"
( (
"<xsl:value-of select="concat( $nearside, 'Link')"/>" <xsl:call-template name="sql-type"> "<xsl:value-of select="concat( $nearside, $linksuffix)"/>" <xsl:call-template name="sql-type">
<xsl:with-param name="property" select="//adl:entity[@name=$nearside]/adl:key/adl:property[position()=1]"/> <xsl:with-param name="property" select="//adl:entity[@name=$nearside]/adl:key/adl:property[position()=1]"/>
</xsl:call-template> NOT NULL, </xsl:call-template> NOT NULL,
"<xsl:value-of select="concat( $farside, 'Link')"/>" <xsl:call-template name="sql-type"> "<xsl:value-of select="concat( $farside, $linksuffix)"/>" <xsl:call-template name="sql-type">
<xsl:with-param name="property" select="$farentity/adl:key/adl:property[position()=1]"/> <xsl:with-param name="property" select="$farentity/adl:key/adl:property[position()=1]"/>
</xsl:call-template> NOT NULL </xsl:call-template> NOT NULL
) )
@ -526,13 +551,13 @@
<xsl:call-template name="foreignkey"> <xsl:call-template name="foreignkey">
<xsl:with-param name="nearside" select="$linktablename"/> <xsl:with-param name="nearside" select="$linktablename"/>
<xsl:with-param name="farside" select="$neartable"/> <xsl:with-param name="farside" select="$neartable"/>
<xsl:with-param name="linkfield" select="concat( $nearside, 'Link')"/> <xsl:with-param name="linkfield" select="concat( $nearside, $linksuffix)"/>
<xsl:with-param name="ondelete" select="'NO ACTION'"/> <xsl:with-param name="ondelete" select="'NO ACTION'"/>
</xsl:call-template> </xsl:call-template>
<xsl:call-template name="foreignkey"> <xsl:call-template name="foreignkey">
<xsl:with-param name="nearside" select="$linktablename"/> <xsl:with-param name="nearside" select="$linktablename"/>
<xsl:with-param name="farside" select="$fartable"/> <xsl:with-param name="farside" select="$fartable"/>
<xsl:with-param name="linkfield" select="concat( $farside, 'Link')"/> <xsl:with-param name="linkfield" select="concat( $farside, $linksuffix)"/>
<xsl:with-param name="ondelete" select="'CASCADE'"/> <xsl:with-param name="ondelete" select="'CASCADE'"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
@ -540,13 +565,13 @@
<xsl:call-template name="foreignkey"> <xsl:call-template name="foreignkey">
<xsl:with-param name="nearside" select="$linktablename"/> <xsl:with-param name="nearside" select="$linktablename"/>
<xsl:with-param name="farside" select="$neartable"/> <xsl:with-param name="farside" select="$neartable"/>
<xsl:with-param name="linkfield" select="concat( $nearside, 'Link')"/> <xsl:with-param name="linkfield" select="concat( $nearside, $linksuffix)"/>
<xsl:with-param name="ondelete" select="'CASCADE'"/> <xsl:with-param name="ondelete" select="'CASCADE'"/>
</xsl:call-template> </xsl:call-template>
<xsl:call-template name="foreignkey"> <xsl:call-template name="foreignkey">
<xsl:with-param name="nearside" select="$linktablename"/> <xsl:with-param name="nearside" select="$linktablename"/>
<xsl:with-param name="farside" select="$fartable"/> <xsl:with-param name="farside" select="$fartable"/>
<xsl:with-param name="linkfield" select="concat( @entity, 'Link')"/> <xsl:with-param name="linkfield" select="concat( @entity, $linksuffix)"/>
<xsl:with-param name="ondelete" select="'CASCADE'"/> <xsl:with-param name="ondelete" select="'CASCADE'"/>
</xsl:call-template> </xsl:call-template>
</xsl:otherwise> </xsl:otherwise>
@ -742,7 +767,7 @@
<xsl:when test="$base-type = 'timestamp'">DATETIME</xsl:when> <xsl:when test="$base-type = 'timestamp'">DATETIME</xsl:when>
<xsl:when test="$base-type = 'integer'">INT</xsl:when> <xsl:when test="$base-type = 'integer'">INT</xsl:when>
<xsl:when test="$base-type = 'real'">DOUBLE PRECISION</xsl:when> <xsl:when test="$base-type = 'real'">DOUBLE PRECISION</xsl:when>
<xsl:when test="$base-type = 'money'">DECIMAL( 16,2)</xsl:when> <xsl:when test="$base-type = 'money'">DECIMAL( 16, 2)</xsl:when>
<xsl:otherwise>[sql:unknown? [<xsl:value-of select="$base-type"/>]]</xsl:otherwise> <xsl:otherwise>[sql:unknown? [<xsl:value-of select="$base-type"/>]]</xsl:otherwise>
</xsl:choose> </xsl:choose>