Many fixes, including global enforcement of UTF-8

This commit is contained in:
sb 2008-02-07 16:35:00 +00:00
parent 7f5585d492
commit f64f137a67
7 changed files with 161 additions and 105 deletions

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Application Description Language framework
adl2canonical.xsl
@ -16,8 +16,8 @@
are generated.
$Author: sb $
$Revision: 1.3 $
$Date: 2008-02-04 15:54:46 $
$Revision: 1.4 $
$Date: 2008-02-07 16:35:00 $
-->
<xsl:stylesheet version="1.0"
@ -47,7 +47,7 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED.
*
* Generated using adl2canonical.xsl revision <xsl:value-of select="substring('$Revision: 1.3 $', 12)"/>
* Generated using adl2canonical.xsl revision <xsl:value-of select="substring('$Revision: 1.4 $', 12)"/>
*
***************************************************************************
</xsl:comment>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:nhibernate-mapping-2.2">
xmlns:adl="http://cygnets.co.uk/schemas/adl-1.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:hbn="urn:nhibernate-mapping-2.2">
<!--
Application Description Framework
adl2hibernate.xsl
@ -11,20 +12,31 @@
Transform ADL to Hibernate
$Author: sb $
$Revision: 1.1 $
$Revision: 1.2 $
-->
<xsl:output indent="no" method="xml" encoding="utf-8"/>
<!--
The convention to use for naming auto-generated abstract primary keys. Known values are
Id - the autogenerated primary key, if any, is called just 'Id'
Name - the autogenerated primary key has the same name as the entity
NameId - 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:output indent="yes" method="xml" encoding="UTF-8"/>
<!-- 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
does not tag-minimize on output. If you change this the build will break, you
have been warned! -->
<xsl:include href="csharp-type-include.xslt"/>
<xsl:variable name="namespace">SRU.Hospitality.Entities</xsl:variable>
<xsl:variable name="assembly">SRU.Hospitality.DataModel</xsl:variable>
<xsl:template match="application">
<hibernate-mapping>
<xsl:template match="adl:application">
<hbn:hibernate-mapping>
<xsl:attribute name="namespace">
<xsl:value-of select="$namespace"/>
</xsl:attribute>
@ -41,108 +53,153 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED.
*
* Generated using adl2hibernate-mapping.xsl revision <xsl:value-of select="substring('$Revision: 1.1 $', 12)"/>
* Generated using adl2hibernate-mapping.xsl revision <xsl:value-of select="substring('$Revision: 1.2 $', 12)"/>
*
***************************************************************************
</xsl:comment>
<xsl:apply-templates select="entity"/>
</hibernate-mapping>
<xsl:apply-templates select="adl:entity"/>
</hbn:hibernate-mapping>
</xsl:template>
<xsl:template match="entity">
<class>
<xsl:template match="adl:entity[@foreign='true']"/>
<xsl:template match="adl:entity">
<xsl:apply-templates select="adl:documentation"/>
<hbn:class>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="table">
<xsl:value-of select="@name"/>
</xsl:attribute>
<id type="Int32">
<!-- ADL does not encode the primary key explicitly; instead it is
implicit and its name is always the name of the entity followed by
'Id' -->
<xsl:attribute name="name">
<xsl:value-of select="normalize-space( concat( @name, 'Id'))"/>
</xsl:attribute>
<generator class="native"/>
</id>
<xsl:apply-templates select="property"/>
</class>
<xsl:apply-templates select="adl:key"/>
<xsl:apply-templates select="adl:property"/>
</hbn:class>
</xsl:template>
<xsl:template match="property[@concrete='false']">
<xsl:template match="adl:key">
<xsl:choose>
<xsl:when test="count( property) = 0"/>
<xsl:when test="count( property) = 1">
<hbn:id>
<xsl:attribute name="name">
<xsl:value-of select="adl:property[position()=1]/@name"/>
</xsl:attribute>
<xsl:attribute name="column">
<xsl:choose>
<xsl:when test="adl:property[position()=1]/@column">
<xsl:value-of select="adl:property[position()=1]/@column"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="adl:property[position()=1]/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="adl:property[position()=1]"/>
</xsl:call-template>
</xsl:attribute>
<xsl:apply-templates select="adl:generator"/>
</hbn:id>
</xsl:when>
<xsl:otherwise>
<xsl:comment>Composite primary key - not yet implemented in adl2hibernate</xsl:comment>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:generator">
<hbn:generator>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@action='manual'">
<xsl:value-of select="@class"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@action"/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</hbn:generator>
</xsl:template>
<xsl:template match="adl:property[@concrete='false']">
<!-- properties which are not concrete are by definition not
stored in the database -->
</xsl:template>
<xsl:template match="property[@type='entity']">
<xsl:template match="adl:property[@type='entity']">
<!-- a property of type entity translates to a Hibernate many-to-one -->
<many-to-one>
<hbn:many-to-one>
<xsl:apply-templates select="adl:documentation"/>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
</xsl:attribute>
<!-- xsl:choose>
<xsl:choose>
<xsl:when test="@cascade='manual'"/>
<xsl:when test="@cascade">
<xsl:attribute name="cascade">
<xsl:value-of select="@cascade"/>
</xsl:attribute>
</xsl:when>
</xsl:choose -->
</many-to-one>
</xsl:choose>
</hbn:many-to-one>
</xsl:template>
<xsl:template match="property[@type='list']">
<xsl:template match="adl:property[@type='list']">
<xsl:variable name="farent" select="@entity"/>
<xsl:variable name="nearent" select="ancestor::entity/@name"/>
<xsl:variable name="nearent" select="ancestor::adl:entity/@name"/>
<xsl:variable name="farkey">
<xsl:choose>
<xsl:when test="@farkey">
<xsl:value-of select="@farkey"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="ancestor::entity/@name"/>
<xsl:value-of select="ancestor::adl:entity/@name"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<set>
<hbn:set>
<xsl:apply-templates select="adl:documentation"/>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="inverse">
<!-- true if the other end of the link is described in the ADL (which it normally will be) -->
<xsl:choose>
<xsl:when test="//entity[@name=$farent]/property[@name=$farkey and @entity=$nearent]">true</xsl:when>
<xsl:when test="//adl:entity[@name=$farent]/adl:property[@name=$farkey and @entity=$nearent]">true</xsl:when>
<xsl:otherwise>false</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<!-- careful with reformatting here:
'The element cannot contain white space. Content model is empty.' -->
<key><xsl:attribute name="column">
<hbn:key><xsl:attribute name="column">
<!-- this is the name of the farside foreign key field which points to me -->
<xsl:value-of select="$farkey"/>
</xsl:attribute></key>
<one-to-many>
</xsl:attribute>
</hbn:key>
<hbn:one-to-many>
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
</xsl:attribute>
</one-to-many>
<!-- xsl:choose>
</hbn:one-to-many>
<xsl:choose>
<xsl:when test="@cascade='manual'"/>
<xsl:when test="@cascade">
<xsl:attribute name="cascade">
<xsl:value-of select="@cascade"/>
</xsl:attribute>
</xsl:when>
</xsl:choose -->
</set>
</xsl:choose>
</hbn:set>
</xsl:template>
<xsl:template match="property[@type='link']">
<xsl:template match="adl:property[@type='link']">
<!-- a property of type 'link' maps on to a Hibernate set -->
<xsl:variable name="comparison">
<xsl:call-template name="stringcompare">
@ -161,19 +218,20 @@
</xsl:choose>
</xsl:variable>
<set>
<hbn:set>
<xsl:apply-templates select="adl:documentation"/>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="table">
<xsl:value-of select="$tablename"/>
</xsl:attribute>
<key>
<hbn:key>
<xsl:attribute name="column">
<xsl:value-of select="concat( ../@name, 'Id')"/>
</xsl:attribute>
</key>
<many-to-many>
</hbn:key>
<hbn:many-to-many>
<xsl:attribute name="column">
<xsl:choose>
<xsl:when test="../@name = @entity">
@ -187,46 +245,31 @@
<xsl:attribute name="class">
<xsl:value-of select="@entity"/>
</xsl:attribute>
</many-to-many>
</set>
</hbn:many-to-many>
</hbn:set>
</xsl:template>
<xsl:template match="property">
<xsl:template match="adl:property">
<!-- tricky, this, because we're translating between ADL properties and
Hibernate properties, which are (slightly) different. There's potential
for confusion -->
<property>
<hbn:property>
<xsl:apply-templates select="adl:documentation"/>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="type">
<xsl:variable name="type">
<xsl:choose>
<xsl:when test="@type = 'defined'">
<xsl:variable name="definition">
<xsl:value-of select="@definition"/>
</xsl:variable>
<xsl:value-of select="/application/definition[@name=$definition]/@type"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@type"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="$type = 'date'">DateTime</xsl:when>
<xsl:when test="$type = 'time'">DateTime</xsl:when>
<xsl:when test="$type = 'string'">String</xsl:when>
<xsl:when test="$type = 'text'">String</xsl:when>
<xsl:when test="$type = 'boolean'">Boolean</xsl:when>
<xsl:when test="$type = 'timestamp'">TimeStamp</xsl:when>
<xsl:when test="$type = 'integer'">Int32</xsl:when>
<xsl:when test="$type = 'real'">Double</xsl:when>
<xsl:when test="$type = 'money'">Decimal</xsl:when>
<xsl:otherwise>[unknown?]</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="csharp-type">
<xsl:with-param name="property" select="."/>
</xsl:call-template>
</xsl:attribute>
</property>
</hbn:property>
</xsl:template>
<xsl:template name="adl:documentation">
<xsl:comment>
<xsl:apply-templates/>
</xsl:comment>
</xsl:template>
<!--

View file

@ -12,10 +12,10 @@
Convert ADL to MS-SQL
$Author: sb $
$Revision: 1.4 $
$Revision: 1.5 $
-->
<xsl:output indent="no" encoding="utf-8" method="text"/>
<xsl:output indent="no" encoding="UTF-8" method="text"/>
<xsl:include href="base-type-include.xslt"/>
<!--
@ -31,7 +31,7 @@
-------------------------------------------------------------------------------------------------
--
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@version"/>
-- Generated for MS-SQL 2000+ using adl2mssql.xsl $Revision: 1.4 $
-- Generated for MS-SQL 2000+ using adl2mssql.xsl $Revision: 1.5 $
--
-- Code generator (c) 2007 Cygnet Solutions Ltd
--
@ -469,7 +469,6 @@
</xsl:template>
<xsl:template name="primary-key-name">
<!-- return the name of the primary key of the entity with this name -->
<xsl:param name="entityname"/>
<xsl:choose>
<xsl:when test="//adl:entity[@name=$entityname]/@natural-key">
@ -522,17 +521,31 @@
</xsl:variable>
<xsl:choose>
<xsl:when test="$base-type = 'entity'">
<xsl:variable name="entity" select="@entity"/>
<xsl:call-template name="sql-type">
<xsl:with-param name="property"
select="//adl:entity[@name=$entity]/adl:key/adl:property[position()=1]"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="$base-type = 'link'">
ICollection&lt;<xsl:value-of select="@entity"/>&gt;
</xsl:when>
<xsl:when test="$base-type = 'list'">
ICollection&lt;<xsl:value-of select="@entity"/>&gt;
<xsl:variable name="entity" select="$property/@entity"/>
<xsl:choose>
<xsl:when test="//adl:entity[@name=$entity]">
<xsl:choose>
<xsl:when test="//adl:entity[@name=$entity]/adl:key/adl:property">
<xsl:call-template name="sql-type">
<xsl:with-param name="property"
select="//adl:entity[@name=$entity]/adl:key/adl:property[position()=1]"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: property '<xsl:value-of select="$property/@name"/>' refers to
entity '<xsl:value-of select="$property/@entity"/>', but this entity has not key.
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">
ADL: ERROR: property '<xsl:value-of select="$property/@name"/>' refers to
entity '<xsl:value-of select="$property/@entity"/>', but no such entity exists.
</xsl:message>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$base-type = 'date'">DATETIME</xsl:when>
<xsl:when test="$base-type = 'time'">DATETIME</xsl:when>

View file

@ -31,7 +31,7 @@
<!--
JACQUARD 2 APPLICATION DESCRIPTION LANGUAGE FRAMEWORK
$Revision: 1.1 $
$Revision: 1.2 $
NOTES:
@ -48,13 +48,13 @@
two removes (i.e. the 'distinguish' mechanism in ADL
-->
<xsl:output indent="no" encoding="utf-8" method="text"/>
<xsl:output indent="no" encoding="UTF-8" method="text"/>
<xsl:template match="application">
-------------------------------------------------------------------------------------------------
--
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@version"/>
-- Generated for PostgreSQL [7|8] using adl2psql.xsl $Revision: 1.1 $
-- Generated for PostgreSQL [7|8] using adl2psql.xsl $Revision: 1.2 $
--
-- Code generator (c) 2006 Simon Brooke [simon@weft.co.uk]
-- http://www.weft.co.uk/library/jacquard/

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Application Description Language framework
base-type-include.xslt
@ -10,8 +10,8 @@
one place for ease of maintenance
$Author: sb $
$Revision: 1.2 $
$Date: 2008-02-04 15:53:32 $
$Revision: 1.3 $
$Date: 2008-02-07 16:35:00 $
-->
<xsl:stylesheet version="1.0"

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Application Description Language framework
csharp-type-include.xslt
@ -10,8 +10,8 @@
one place for ease of maintenance
$Author: sb $
$Revision: 1.1 $
$Date: 2008-02-01 21:47:15 $
$Revision: 1.2 $
$Date: 2008-02-07 16:35:00 $
-->
<xsl:stylesheet version="1.0"

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output encoding="utf-8" method="html" indent="yes" />
<xsl:output encoding="UTF-8" method="html" indent="yes" />
<xsl:param name="locale" select="en-UK"/>