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 Application Description Language framework
adl2canonical.xsl adl2canonical.xsl
@ -16,8 +16,8 @@
are generated. are generated.
$Author: sb $ $Author: sb $
$Revision: 1.3 $ $Revision: 1.4 $
$Date: 2008-02-04 15:54:46 $ $Date: 2008-02-07 16:35:00 $
--> -->
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
@ -47,7 +47,7 @@
* 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.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> </xsl:comment>

View file

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" <xsl:stylesheet version="1.0"
xmlns:adl="http://cygnets.co.uk/schemas/adl-1.2"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="urn:nhibernate-mapping-2.2"> xmlns:hbn="urn:nhibernate-mapping-2.2">
<!-- <!--
Application Description Framework Application Description Framework
adl2hibernate.xsl adl2hibernate.xsl
@ -11,20 +12,31 @@
Transform ADL to Hibernate Transform ADL to Hibernate
$Author: sb $ $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 <!-- 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
does not tag-minimize on output. If you change this the build will break, you does not tag-minimize on output. If you change this the build will break, you
have been warned! --> have been warned! -->
<xsl:include href="csharp-type-include.xslt"/>
<xsl:variable name="namespace">SRU.Hospitality.Entities</xsl:variable> <xsl:variable name="namespace">SRU.Hospitality.Entities</xsl:variable>
<xsl:variable name="assembly">SRU.Hospitality.DataModel</xsl:variable> <xsl:variable name="assembly">SRU.Hospitality.DataModel</xsl:variable>
<xsl:template match="application"> <xsl:template match="adl:application">
<hibernate-mapping> <hbn:hibernate-mapping>
<xsl:attribute name="namespace"> <xsl:attribute name="namespace">
<xsl:value-of select="$namespace"/> <xsl:value-of select="$namespace"/>
</xsl:attribute> </xsl:attribute>
@ -41,108 +53,153 @@
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT * THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
* BE MANUALLY EDITED. * 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:comment>
<xsl:apply-templates select="entity"/> <xsl:apply-templates select="adl:entity"/>
</hibernate-mapping> </hbn:hibernate-mapping>
</xsl:template> </xsl:template>
<xsl:template match="entity"> <xsl:template match="adl:entity[@foreign='true']"/>
<class>
<xsl:template match="adl:entity">
<xsl:apply-templates select="adl:documentation"/>
<hbn:class>
<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="table"> <xsl:attribute name="table">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</xsl:attribute> </xsl:attribute>
<id type="Int32"> <xsl:apply-templates select="adl:key"/>
<!-- ADL does not encode the primary key explicitly; instead it is <xsl:apply-templates select="adl:property"/>
implicit and its name is always the name of the entity followed by </hbn:class>
'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:template> </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 <!-- properties which are not concrete are by definition not
stored in the database --> stored in the database -->
</xsl:template> </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 --> <!-- 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:attribute name="name">
<xsl:value-of select="@name"/> <xsl:value-of select="@name"/>
</xsl:attribute> </xsl:attribute>
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="@entity"/> <xsl:value-of select="@entity"/>
</xsl:attribute> </xsl:attribute>
<!-- xsl:choose> <xsl:choose>
<xsl:when test="@cascade='manual'"/> <xsl:when test="@cascade='manual'"/>
<xsl:when test="@cascade"> <xsl:when test="@cascade">
<xsl:attribute name="cascade"> <xsl:attribute name="cascade">
<xsl:value-of select="@cascade"/> <xsl:value-of select="@cascade"/>
</xsl:attribute> </xsl:attribute>
</xsl:when> </xsl:when>
</xsl:choose --> </xsl:choose>
</many-to-one> </hbn:many-to-one>
</xsl:template> </xsl:template>
<xsl:template match="property[@type='list']"> <xsl:template match="adl:property[@type='list']">
<xsl:variable name="farent" select="@entity"/> <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:variable name="farkey">
<xsl:choose> <xsl:choose>
<xsl:when test="@farkey"> <xsl:when test="@farkey">
<xsl:value-of select="@farkey"/> <xsl:value-of select="@farkey"/>
</xsl:when> </xsl:when>
<xsl:otherwise> <xsl:otherwise>
<xsl:value-of select="ancestor::entity/@name"/> <xsl:value-of select="ancestor::adl:entity/@name"/>
</xsl:otherwise> </xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<set> <hbn:set>
<xsl:apply-templates select="adl:documentation"/>
<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="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>
<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:otherwise>false</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
<!-- careful with reformatting here: <!-- careful with reformatting here:
'The element cannot contain white space. Content model is empty.' --> '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 --> <!-- this is the name of the farside foreign key field which points to me -->
<xsl:value-of select="$farkey"/> <xsl:value-of select="$farkey"/>
</xsl:attribute></key> </xsl:attribute>
<one-to-many> </hbn:key>
<hbn:one-to-many>
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="@entity"/> <xsl:value-of select="@entity"/>
</xsl:attribute> </xsl:attribute>
</one-to-many> </hbn: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">
<xsl:attribute name="cascade"> <xsl:attribute name="cascade">
<xsl:value-of select="@cascade"/> <xsl:value-of select="@cascade"/>
</xsl:attribute> </xsl:attribute>
</xsl:when> </xsl:when>
</xsl:choose --> </xsl:choose>
</set> </hbn:set>
</xsl:template> </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 --> <!-- a property of type 'link' maps on to a Hibernate set -->
<xsl:variable name="comparison"> <xsl:variable name="comparison">
<xsl:call-template name="stringcompare"> <xsl:call-template name="stringcompare">
@ -161,19 +218,20 @@
</xsl:choose> </xsl:choose>
</xsl:variable> </xsl:variable>
<set> <hbn:set>
<xsl:apply-templates select="adl:documentation"/>
<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="table"> <xsl:attribute name="table">
<xsl:value-of select="$tablename"/> <xsl:value-of select="$tablename"/>
</xsl:attribute> </xsl:attribute>
<key> <hbn:key>
<xsl:attribute name="column"> <xsl:attribute name="column">
<xsl:value-of select="concat( ../@name, 'Id')"/> <xsl:value-of select="concat( ../@name, 'Id')"/>
</xsl:attribute> </xsl:attribute>
</key> </hbn:key>
<many-to-many> <hbn: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">
@ -187,46 +245,31 @@
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:value-of select="@entity"/> <xsl:value-of select="@entity"/>
</xsl:attribute> </xsl:attribute>
</many-to-many> </hbn:many-to-many>
</set> </hbn:set>
</xsl:template> </xsl:template>
<xsl:template match="property"> <xsl:template match="adl:property">
<!-- tricky, this, because we're translating between ADL properties and <!-- tricky, this, because we're translating between ADL properties and
Hibernate properties, which are (slightly) different. There's potential Hibernate properties, which are (slightly) different. There's potential
for confusion --> for confusion -->
<property> <hbn:property>
<xsl:apply-templates select="adl:documentation"/>
<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="type"> <xsl:attribute name="type">
<xsl:variable name="type"> <xsl:call-template name="csharp-type">
<xsl:choose> <xsl:with-param name="property" select="."/>
<xsl:when test="@type = 'defined'"> </xsl:call-template>
<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:attribute> </xsl:attribute>
</property> </hbn:property>
</xsl:template>
<xsl:template name="adl:documentation">
<xsl:comment>
<xsl:apply-templates/>
</xsl:comment>
</xsl:template> </xsl:template>
<!-- <!--

View file

@ -12,10 +12,10 @@
Convert ADL to MS-SQL Convert ADL to MS-SQL
$Author: sb $ $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"/> <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"/> -- 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 -- Code generator (c) 2007 Cygnet Solutions Ltd
-- --
@ -469,7 +469,6 @@
</xsl:template> </xsl:template>
<xsl:template name="primary-key-name"> <xsl:template name="primary-key-name">
<!-- return the name of the primary key of the entity with this name -->
<xsl:param name="entityname"/> <xsl:param name="entityname"/>
<xsl:choose> <xsl:choose>
<xsl:when test="//adl:entity[@name=$entityname]/@natural-key"> <xsl:when test="//adl:entity[@name=$entityname]/@natural-key">
@ -522,17 +521,31 @@
</xsl:variable> </xsl:variable>
<xsl:choose> <xsl:choose>
<xsl:when test="$base-type = 'entity'"> <xsl:when test="$base-type = 'entity'">
<xsl:variable name="entity" select="@entity"/> <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:call-template name="sql-type">
<xsl:with-param name="property" <xsl:with-param name="property"
select="//adl:entity[@name=$entity]/adl:key/adl:property[position()=1]"/> select="//adl:entity[@name=$entity]/adl:key/adl:property[position()=1]"/>
</xsl:call-template> </xsl:call-template>
</xsl:when> </xsl:when>
<xsl:when test="$base-type = 'link'"> <xsl:otherwise>
ICollection&lt;<xsl:value-of select="@entity"/>&gt; <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:when>
<xsl:when test="$base-type = 'list'"> <xsl:otherwise>
ICollection&lt;<xsl:value-of select="@entity"/>&gt; <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>
<xsl:when test="$base-type = 'date'">DATETIME</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 = 'time'">DATETIME</xsl:when>

View file

@ -31,7 +31,7 @@
<!-- <!--
JACQUARD 2 APPLICATION DESCRIPTION LANGUAGE FRAMEWORK JACQUARD 2 APPLICATION DESCRIPTION LANGUAGE FRAMEWORK
$Revision: 1.1 $ $Revision: 1.2 $
NOTES: NOTES:
@ -48,13 +48,13 @@
two removes (i.e. the 'distinguish' mechanism in ADL 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"> <xsl:template match="application">
------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------
-- --
-- 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 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] -- Code generator (c) 2006 Simon Brooke [simon@weft.co.uk]
-- http://www.weft.co.uk/library/jacquard/ -- 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 Application Description Language framework
base-type-include.xslt base-type-include.xslt
@ -10,8 +10,8 @@
one place for ease of maintenance one place for ease of maintenance
$Author: sb $ $Author: sb $
$Revision: 1.2 $ $Revision: 1.3 $
$Date: 2008-02-04 15:53:32 $ $Date: 2008-02-07 16:35:00 $
--> -->
<xsl:stylesheet version="1.0" <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 Application Description Language framework
csharp-type-include.xslt csharp-type-include.xslt
@ -10,8 +10,8 @@
one place for ease of maintenance one place for ease of maintenance
$Author: sb $ $Author: sb $
$Revision: 1.1 $ $Revision: 1.2 $
$Date: 2008-02-01 21:47:15 $ $Date: 2008-02-07 16:35:00 $
--> -->
<xsl:stylesheet version="1.0" <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: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"/> <xsl:param name="locale" select="en-UK"/>