This is a work-in-progress commit while trying to produce grand unified ADL.
Applied Sweepers /does/ build with this version; SRU still /does not/ build with this version.
This commit is contained in:
parent
1abaead774
commit
be2cc24ea7
|
@ -20,402 +20,408 @@
|
|||
explicitly state the permission, even if it is 'none'.
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.9 $
|
||||
$Date: 2008-05-09 16:12:12 $
|
||||
$Revision: 1.10 $
|
||||
$Date: 2008-05-21 13:00:55 $
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
xmlns="http://cygnets.co.uk/schemas/adl-1.2"
|
||||
xmlns="http://cygnets.co.uk/schemas/adl-1.2"
|
||||
xmlns:adl="http://cygnets.co.uk/schemas/adl-1.2"
|
||||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||
exclude-result-prefixes="adl">
|
||||
|
||||
<xsl:output encoding="UTF-8" indent="yes" method="xml" />
|
||||
<xsl:output encoding="UTF-8" indent="yes" method="xml" />
|
||||
|
||||
<!--
|
||||
<!--
|
||||
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:param name="abstract-key-name-convention" select="Id"/>
|
||||
|
||||
<!-- a prefix to prepend to all tablenames -->
|
||||
<xsl:param name="tablename-prefix"/>
|
||||
<!-- the name and version of the product being built -->
|
||||
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
|
||||
|
||||
<xsl:template match="adl:application">
|
||||
<xsl:copy>
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="@version">
|
||||
<xsl:attribute name="version">
|
||||
<xsl:value-of select="@version"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:comment>
|
||||
<!-- a prefix to prepend to all tablenames -->
|
||||
<xsl:param name="tablename-prefix"/>
|
||||
|
||||
<xsl:template match="adl:application">
|
||||
<xsl:copy>
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:if test="@version">
|
||||
<xsl:attribute name="version">
|
||||
<xsl:value-of select="@version"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
|
||||
<xsl:comment>
|
||||
***************************************************************************
|
||||
*
|
||||
* Application Description Language framework
|
||||
* ©2007 Cygnet Solutions Ltd
|
||||
* <xsl:value-of select="$product-version"/>
|
||||
* ©2007 Cygnet Solutions Ltd
|
||||
*
|
||||
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
|
||||
* BE MANUALLY EDITED.
|
||||
* THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
|
||||
* BE MANUALLY EDITED.
|
||||
*
|
||||
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.9 $', 12)"/>
|
||||
*
|
||||
***************************************************************************
|
||||
</xsl:comment>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
* Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.10 $', 12)"/>
|
||||
*
|
||||
***************************************************************************
|
||||
</xsl:comment>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<!-- an entity which already has a key tag - just copy it through -->
|
||||
<xsl:template match="adl:entity[adl:key]">
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:comment>
|
||||
entity <xsl:value-of select="@name"/> already has a key - not generating one
|
||||
</xsl:comment>
|
||||
<entity>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
<!-- an entity which already has a key tag - just copy it through -->
|
||||
<xsl:template match="adl:entity[adl:key]">
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:comment>
|
||||
entity <xsl:value-of select="@name"/> already has a key - not generating one
|
||||
</xsl:comment>
|
||||
<entity>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
|
||||
<!-- an entity which has a '@natural-key' attribute.
|
||||
Since we've got the key tag, I think this should be disallowed -->
|
||||
<xsl:template match="adl:entity[@natural-key]">
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:message terminate="no">
|
||||
ADL WARNING: [In entity '<xsl:value-of select="@name"/>']: '@natural-key' is deprecated - use the 'key' sub element instead</xsl:message>
|
||||
<entity>
|
||||
<xsl:variable name="nkey" select="@natural-key"/>
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<xsl:apply-templates select="adl:content"/>
|
||||
<key>
|
||||
<xsl:apply-templates select="adl:property[@name=$nkey]"/>
|
||||
<xsl:apply-templates select="adl:key/adl:property"/>
|
||||
</key>
|
||||
<xsl:apply-templates select="adl:property[not(@name=$nkey)] | adl:one-to-many | adl:many-to-many | adl:many-to-one"/>
|
||||
<!-- an entity which has a '@natural-key' attribute.
|
||||
Since we've got the key tag, I think this should be disallowed -->
|
||||
<xsl:template match="adl:entity[@natural-key]">
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<xsl:message terminate="no">
|
||||
ADL WARNING: [In entity '<xsl:value-of select="@name"/>']: '@natural-key' is deprecated - use the 'key' sub element instead
|
||||
</xsl:message>
|
||||
<entity>
|
||||
<xsl:variable name="nkey" select="@natural-key"/>
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<xsl:apply-templates select="adl:content"/>
|
||||
<key>
|
||||
<xsl:apply-templates select="adl:property[@name=$nkey]"/>
|
||||
<xsl:apply-templates select="adl:key/adl:property"/>
|
||||
</key>
|
||||
<xsl:apply-templates select="adl:property[not(@name=$nkey)] | adl:one-to-many | adl:many-to-many | adl:many-to-one"/>
|
||||
|
||||
<xsl:variable name="entity" select="."/>
|
||||
<xsl:for-each select="//adl:group">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="."/>
|
||||
<xsl:with-param name="descendantname" select="@name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:apply-templates select="adl:form | adl:page | adl:list"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- an entity which has no explicit key: auto-generate one -->
|
||||
<xsl:template match="adl:entity">
|
||||
<xsl:comment>
|
||||
entity <xsl:value-of select="@name"/> has no key - generating one
|
||||
</xsl:comment>
|
||||
<entity>
|
||||
<!-- copy attributes through -->
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<xsl:apply-templates select="adl:content"/>
|
||||
<key>
|
||||
<!-- autogenerate a key element... -->
|
||||
<!-- select a name... -->
|
||||
<xsl:variable name="key">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$abstract-key-name-convention='Name'">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'NameId'">
|
||||
<xsl:value-of select="concat( @name, 'Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
|
||||
<xsl:value-of select="concat( @name, '_Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="'Id'"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="entity" select="."/>
|
||||
<xsl:for-each select="//adl:group">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="."/>
|
||||
<xsl:with-param name="descendantname" select="@name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
<!-- check that it is unique, and abort hard if not... -->
|
||||
<xsl:if test="descendant::adl:property[@name=$key]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Entity '<xsl:value-of select="@name"/>' has a property '<xsl:value-of select="$key"/>' which conflicts
|
||||
with your chosen key naming convention <xsl:value-of select="$abstract-key-name-convention"/>. Either:
|
||||
(i) Make property '<xsl:value-of select="$key"/>' an explicit key by putting it in the <key> tag;
|
||||
(ii) Name property '<xsl:value-of select="$key"/>' something else; or
|
||||
(iii) Choose a different key naming convention.
|
||||
</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<!-- generate one property, the abstract primary key -->
|
||||
<property type="integer" distinct="system">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="normalize-space( $key)"/>
|
||||
</xsl:attribute>
|
||||
<generator action="native"/>
|
||||
<documentation>
|
||||
Auto-generated abstract primary key
|
||||
</documentation>
|
||||
</property>
|
||||
</key>
|
||||
<xsl:apply-templates select="adl:property | adl:one-to-many | adl:many-to-many | adl:many-to-one"/>
|
||||
<xsl:apply-templates select="adl:form | adl:page | adl:list"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:variable name="entity" select="."/>
|
||||
<xsl:for-each select="//adl:group">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="."/>
|
||||
<xsl:with-param name="descendantname" select="@name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:apply-templates select="adl:form | adl:page | adl:list"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
<!-- an entity which has no explicit key: auto-generate one -->
|
||||
<xsl:template match="adl:entity">
|
||||
<xsl:comment>
|
||||
entity <xsl:value-of select="@name"/> has no key - generating one
|
||||
</xsl:comment>
|
||||
|
||||
<entity>
|
||||
<!-- copy attributes through -->
|
||||
<xsl:apply-templates select="@*"/>
|
||||
<xsl:if test="not( @table)">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, @name)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:if>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<xsl:apply-templates select="adl:content"/>
|
||||
<key>
|
||||
<!-- autogenerate a key element... -->
|
||||
<!-- select a name... -->
|
||||
<xsl:variable name="key">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$abstract-key-name-convention='Name'">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'NameId'">
|
||||
<xsl:value-of select="concat( @name, 'Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
|
||||
<xsl:value-of select="concat( @name, '_Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="'Id'"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
<xsl:template match="@table">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, .)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
<!-- check that it is unique, and abort hard if not... -->
|
||||
<xsl:if test="descendant::adl:property[@name=$key]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Entity '<xsl:value-of select="@name"/>' has a property '<xsl:value-of select="$key"/>' which conflicts
|
||||
with your chosen key naming convention <xsl:value-of select="$abstract-key-name-convention"/>. Either:
|
||||
(i) Make property '<xsl:value-of select="$key"/>' an explicit key by putting it in the <key> tag;
|
||||
(ii) Name property '<xsl:value-of select="$key"/>' something else; or
|
||||
(iii) Choose a different key naming convention.
|
||||
</xsl:message>
|
||||
</xsl:if>
|
||||
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
<!-- generate one property, the abstract primary key -->
|
||||
<property type="integer" distinct="system">
|
||||
<xsl:attribute name="name">
|
||||
<xsl:value-of select="normalize-space( $key)"/>
|
||||
</xsl:attribute>
|
||||
<generator action="native"/>
|
||||
<documentation>
|
||||
Auto-generated abstract primary key
|
||||
</documentation>
|
||||
</property>
|
||||
</key>
|
||||
<xsl:apply-templates select="adl:property | adl:one-to-many | adl:many-to-many | adl:many-to-one"/>
|
||||
|
||||
<xsl:variable name="entity" select="."/>
|
||||
<xsl:for-each select="//adl:group">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="."/>
|
||||
<xsl:with-param name="descendantname" select="@name"/>
|
||||
</xsl:call-template>
|
||||
</xsl:for-each>
|
||||
|
||||
<xsl:apply-templates select="adl:form | adl:page | adl:list"/>
|
||||
</entity>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="@table">
|
||||
<xsl:attribute name="table">
|
||||
<xsl:value-of select="concat( $tablename-prefix, .)"/>
|
||||
</xsl:attribute>
|
||||
</xsl:template>
|
||||
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
We need to do this for lists, pages and forms; there's probably some clever
|
||||
way of doing it all in a oner, but I don't know what that is -->
|
||||
<xsl:template match="adl:form[ @properties='all']">
|
||||
<form properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:form[ @properties='all']">
|
||||
<form properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</form>
|
||||
</xsl:template>
|
||||
</form>
|
||||
</xsl:template>
|
||||
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
We need to do this for lists, pages and forms; there's probably some clever
|
||||
way of doing it all in a oner, but I don't know what that is -->
|
||||
<xsl:template match="adl:page[ @properties='all']">
|
||||
<page properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:page[ @properties='all']">
|
||||
<page properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</page>
|
||||
</xsl:template>
|
||||
</page>
|
||||
</xsl:template>
|
||||
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
<!-- If properties='all', unroll them into a properties='listed' form.
|
||||
We need to do this for lists, pages and forms; there's probably some clever
|
||||
way of doing it all in a oner, but I don't know what that is -->
|
||||
<xsl:template match="adl:list[ @properties='all']">
|
||||
<list properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:list[ @properties='all']">
|
||||
<list properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-properties"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</list>
|
||||
</xsl:template>
|
||||
</list>
|
||||
</xsl:template>
|
||||
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
but the grammar allows this for pages and forms as well so we'll deal with it -->
|
||||
<xsl:template match="adl:form[ @properties='user-distinct']">
|
||||
<form properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:form[ @properties='user-distinct']">
|
||||
<form properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</form>
|
||||
</xsl:template>
|
||||
</form>
|
||||
</xsl:template>
|
||||
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
but the grammar allows this for pages and forms as well so we'll deal with it -->
|
||||
<xsl:template match="adl:page[ @properties='user-distinct']">
|
||||
<page properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:page[ @properties='user-distinct']">
|
||||
<page properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</page>
|
||||
</xsl:template>
|
||||
</page>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
<!-- In practice it's likely only to be lists which have properties='user-distinct',
|
||||
but the grammar allows this for pages and forms as well so we'll deal with it -->
|
||||
<xsl:template match="adl:list[ @properties='user-distinct']">
|
||||
<list properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
<xsl:template match="adl:list[ @properties='user-distinct']">
|
||||
<list properties='listed'>
|
||||
<!-- copy the name attribute through -->
|
||||
<xsl:apply-templates select="@name"/>
|
||||
<!-- children copied through in legal order, to ensure the document remains valid -->
|
||||
<xsl:apply-templates select="adl:documentation"/>
|
||||
<!-- unroll the properties -->
|
||||
<xsl:call-template name="unroll-user-distinct"/>
|
||||
<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
|
||||
adl:fieldgroup|adl:auxlist|adl:verb|
|
||||
adl:permission|adl:pragma"/>
|
||||
</list>
|
||||
</xsl:template>
|
||||
</list>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:typedef[ @type = 'string' and not( @size)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Type definitions of type 'string' must have a valid value for 'size'
|
||||
Offending typedef: <xsl:value-of select="@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
<xsl:template match="adl:typedef[ @type = 'string' and not( @size)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Type definitions of type 'string' must have a valid value for 'size'
|
||||
Offending typedef: <xsl:value-of select="@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<!-- Language constraints -->
|
||||
<xsl:template match="adl:property[ @type = 'string' and not( @size)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'string' must have a valid value for 'size'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
<!-- Language constraints -->
|
||||
<xsl:template match="adl:property[ @type = 'string' and not( @size)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'string' must have a valid value for 'size'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:property[ @type = 'entity' and not( @entity)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'entity' must have a valid value for 'entity'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
<xsl:template match="adl:property[ @type = 'entity' and not( @entity)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'entity' must have a valid value for 'entity'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:property[ @type = 'defined' and not( @typedef)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'defined' must have a valid value for 'typedef'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
<xsl:template match="adl:property[ @type = 'defined' and not( @typedef)]">
|
||||
<xsl:message terminate="yes">
|
||||
ADL ERROR: Properties of type 'defined' must have a valid value for 'typedef'
|
||||
Offending property: <xsl:value-of select="@name"/> of entity <xsl:value-of select="ancestor::adl:entity/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:template>
|
||||
|
||||
|
||||
<!-- copy anything that isn't explicitly matched -->
|
||||
<xsl:template match="@* | node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<!-- copy anything that isn't explicitly matched -->
|
||||
<xsl:template match="@* | node()">
|
||||
<xsl:copy>
|
||||
<xsl:apply-templates select="@* | node()"/>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<!-- generate a permission element for this group and this entity -->
|
||||
<xsl:template name="entity-group-permission">
|
||||
<xsl:param name="entity"/>
|
||||
<xsl:param name="group"/>
|
||||
<xsl:param name="descendantname"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$entity/adl:permission[@group=$group/@name]">
|
||||
<!-- there's an explicit permission for this group -->
|
||||
<permission>
|
||||
<xsl:attribute name="group">
|
||||
<xsl:value-of select="$descendantname"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="permission">
|
||||
<xsl:value-of select="$entity/adl:permission[@group=$group/@name]/@permission"/>
|
||||
</xsl:attribute>
|
||||
</permission>
|
||||
</xsl:when>
|
||||
<xsl:when test="$group/@parent">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$group/@parent = $group/@name">
|
||||
<xsl:message terminate="yes">
|
||||
ADL: ERROR: A group may not be its own parent; offending group <xsl:value-of select="$group/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:when>
|
||||
<xsl:when test="//adl:group[@name=$group/@parent]">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="//adl:group[@name=$group/@parent]"/>
|
||||
<xsl:with-param name="descendantname" select="$descendantname"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">
|
||||
ADL: ERROR: Group specified (<xsl:value-of select="$group/@parent"/> does not exist.
|
||||
</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<permission permission="none">
|
||||
<xsl:attribute name="group">
|
||||
<xsl:value-of select="$descendantname"/>
|
||||
</xsl:attribute>
|
||||
</permission>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
<!-- generate a permission element for this group and this entity -->
|
||||
<xsl:template name="entity-group-permission">
|
||||
<xsl:param name="entity"/>
|
||||
<xsl:param name="group"/>
|
||||
<xsl:param name="descendantname"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$entity/adl:permission[@group=$group/@name]">
|
||||
<!-- there's an explicit permission for this group -->
|
||||
<permission>
|
||||
<xsl:attribute name="group">
|
||||
<xsl:value-of select="$descendantname"/>
|
||||
</xsl:attribute>
|
||||
<xsl:attribute name="permission">
|
||||
<xsl:value-of select="$entity/adl:permission[@group=$group/@name]/@permission"/>
|
||||
</xsl:attribute>
|
||||
</permission>
|
||||
</xsl:when>
|
||||
<xsl:when test="$group/@parent">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$group/@parent = $group/@name">
|
||||
<xsl:message terminate="yes">
|
||||
ADL: ERROR: A group may not be its own parent; offending group <xsl:value-of select="$group/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:when>
|
||||
<xsl:when test="//adl:group[@name=$group/@parent]">
|
||||
<xsl:call-template name="entity-group-permission">
|
||||
<xsl:with-param name="entity" select="$entity"/>
|
||||
<xsl:with-param name="group" select="//adl:group[@name=$group/@parent]"/>
|
||||
<xsl:with-param name="descendantname" select="$descendantname"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">
|
||||
ADL: ERROR: Group specified (<xsl:value-of select="$group/@parent"/> does not exist.
|
||||
</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<permission permission="none">
|
||||
<xsl:attribute name="group">
|
||||
<xsl:value-of select="$descendantname"/>
|
||||
</xsl:attribute>
|
||||
</permission>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- unroll all the explicit properties in the ancestor entity of
|
||||
<!-- unroll all the explicit properties in the ancestor entity of
|
||||
the context (assumed to be form, page or list) into a list of fields -->
|
||||
<xsl:template name="unroll-properties">
|
||||
<xsl:for-each select="ancestor::adl:entity/descendant::adl:property |
|
||||
<xsl:template name="unroll-properties">
|
||||
<xsl:for-each select="ancestor::adl:entity/descendant::adl:property |
|
||||
ancestor::adl:entity/descendant::adl:one-to-many |
|
||||
ancestor::adl:entity/descendant::adl:many-to-many |
|
||||
ancestor::adl:entity/descendant::adl:many-to-one">
|
||||
<field>
|
||||
<xsl:attribute name="property">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
</field>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
<field>
|
||||
<xsl:attribute name="property">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
</field>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<!-- unroll all the user-distinct properties in the ancestor entity of
|
||||
<!-- unroll all the user-distinct properties in the ancestor entity of
|
||||
the context (assumed to be form, page or list) into a list of fields.
|
||||
NOTE that n-to-n properties cannot currently be user-distinct and are
|
||||
therefore not inspected -->
|
||||
<xsl:template name="unroll-user-distinct">
|
||||
<xsl:for-each select="ancestor::adl:entity/descendant::adl:property[@distinct='user' or @distinct='all']">
|
||||
<field>
|
||||
<xsl:attribute name="property">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:template name="unroll-user-distinct">
|
||||
<xsl:for-each select="ancestor::adl:entity/descendant::adl:property[@distinct='user' or @distinct='all']">
|
||||
<field>
|
||||
<xsl:attribute name="property">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:attribute>
|
||||
<xsl:apply-templates select="adl:prompt"/>
|
||||
<xsl:apply-templates select="adl:help"/>
|
||||
</field>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
</field>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
|
@ -9,8 +9,8 @@
|
|||
Transform ADL into (partial) controller classes
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.29 $
|
||||
$Date: 2008-05-19 14:49:18 $
|
||||
$Revision: 1.30 $
|
||||
$Date: 2008-05-21 13:00:56 $
|
||||
-->
|
||||
|
||||
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
|
||||
|
@ -39,39 +39,34 @@
|
|||
<!-- Whether to authenticate at application or at database layer.
|
||||
If not 'Application', then 'Database'. -->
|
||||
<xsl:param name="authentication-layer" select="Application"/>
|
||||
<!--
|
||||
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"/>
|
||||
|
||||
<!-- the name and version of the product being built -->
|
||||
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
|
||||
|
||||
<!-- bug 1800 : the name of the Velocity layout to use -->
|
||||
<xsl:param name="layout-name" select="adl-default-layout"/>
|
||||
<!-- bug 1800 : the name of the Velocity rescue view to use -->
|
||||
<xsl:param name="rescue-name" select="adl-default-rescue"/>
|
||||
<xsl:param name="rescue-name"/>
|
||||
<!-- bug 1800 : the name of the area (i.e. URL path part) to use -->
|
||||
<xsl:param name="area-name" select="auto"/>
|
||||
<xsl:param name="area-name"/>
|
||||
|
||||
<xsl:template match="adl:application">
|
||||
<xsl:call-template name="collection-factory"/>
|
||||
<xsl:apply-templates select="adl:entity"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="collection-factory">
|
||||
<xsl:template name="collection-factory">
|
||||
/* ---- [ cut here: next file '<xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs'] ---------------- */
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Application Description Language framework
|
||||
// <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/>.auto.cs
|
||||
// <xsl:value-of select="$product-version"/>
|
||||
// <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller.auto.cs')"/>
|
||||
//
|
||||
// (c) 2007 Cygnet Solutions Ltd
|
||||
//
|
||||
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
|
||||
// Automatically generated from application description using
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 10)"/>
|
||||
// Automatically generated abstract super class for controllers for the
|
||||
// <xsl:value-of select="/adl:application/@name"/> application; generated using
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
|
||||
//
|
||||
// This file is automatically generated; DO NOT EDIT IT.
|
||||
//
|
||||
|
@ -82,53 +77,59 @@ using System.Data;
|
|||
using System.Collections.Generic;
|
||||
using NHibernate;
|
||||
using NHibernate.Expression;
|
||||
using Cygnet.Web.Controllers;
|
||||
using <xsl:value-of select="$entityns"/>;
|
||||
|
||||
namespace <xsl:value-of select="$controllerns"/> {
|
||||
|
||||
/// <summary>
|
||||
/// Automatically generated abstract super class for controllers for the
|
||||
/// <xsl:value-of select="/adl:application/@name"/> application
|
||||
///
|
||||
/// DO NOT EDIT THIS FILE!
|
||||
/// </summary>
|
||||
public abstract partial class <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> : BaseController {
|
||||
<xsl:for-each select="//adl:entity">
|
||||
/// <summary>
|
||||
/// Return a list of all instances of <xsl:value-of select="@name"/> for use in menus, etc;
|
||||
/// </summary>
|
||||
protected IList<<xsl:value-of select="concat( $entityns, '.', @name)"/>> <xsl:value-of select="concat( 'FetchAll', @name)"/>( ISession hibernator) {
|
||||
return hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
|
||||
<xsl:for-each select="descendant::adl:property[@distinct='user']">
|
||||
.AddOrder( <xsl:value-of select="concat('new Order( "', @name, '", true)')"/>)
|
||||
</xsl:for-each>
|
||||
.SetCacheable( true)
|
||||
.SetCacheRegion( "<xsl:value-of select="/adl:application/@name"/>")
|
||||
.List<<xsl:value-of select="concat( $entityns, '.', @name)"/>>();
|
||||
}
|
||||
/// <summary>
|
||||
/// Automatically generated abstract super class for controllers for the
|
||||
/// <xsl:value-of select="/adl:application/@name"/> application
|
||||
///
|
||||
/// DO NOT EDIT THIS FILE!
|
||||
/// </summary>
|
||||
public abstract partial class <xsl:value-of select="concat( 'Abstract', /adl:application/@name, 'Controller')"/> : BaseController {
|
||||
<xsl:for-each select="//adl:entity">
|
||||
/// <summary>
|
||||
/// Return a list of all instances of <xsl:value-of select="@name"/> for use in menus, etc;
|
||||
/// </summary>
|
||||
protected IList<<xsl:value-of select="concat( $entityns, '.', @name)"/>> <xsl:value-of select="concat( 'FetchAll', @name)"/>( ISession hibernator) {
|
||||
return hibernator.CreateCriteria(typeof(<xsl:value-of select="concat( $entityns, '.', @name)"/>))
|
||||
<xsl:for-each select="descendant::adl:property[@distinct='user']">
|
||||
.AddOrder( <xsl:value-of select="concat('new Order( "', @name, '", true)')"/>)
|
||||
</xsl:for-each>
|
||||
.SetCacheable( true)
|
||||
.SetCacheRegion( "<xsl:value-of select="/adl:application/@name"/>")
|
||||
.List<<xsl:value-of select="concat( $entityns, '.', @name)"/>>();
|
||||
}
|
||||
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
}
|
||||
}
|
||||
</xsl:template>
|
||||
}
|
||||
</xsl:template>
|
||||
|
||||
<!-- Don't bother generating anything for foreign entities -->
|
||||
<xsl:template match="adl:entity[@foreign='true']"/>
|
||||
|
||||
|
||||
<xsl:template match="adl:entity">
|
||||
<xsl:comment>Not generating controller for entity <xsl:value-of select="@name"/>,
|
||||
as it has no forms, pages or lists.
|
||||
</xsl:comment>
|
||||
</xsl:template>
|
||||
<xsl:template match="adl:entity[adl:form|adl:page|adl:list]">
|
||||
|
||||
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>Controller.auto.cs'] ---------------- */
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// Application Description Language framework
|
||||
// <xsl:value-of select="$product-version"/>
|
||||
// <xsl:value-of select="@name"/>Controller.auto.cs
|
||||
//
|
||||
// (c) 2007 Cygnet Solutions Ltd
|
||||
//
|
||||
// Controller for auto-generated forms for editing <xsl:value-of select="@name"/>s
|
||||
// Automatically generated from application description using
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.29 $', 10)"/>
|
||||
// adl2controllerclasses.xslt version <xsl:value-of select="substring( '$Revision: 1.30 $', 10)"/>
|
||||
//
|
||||
// This file is automatically generated; DO NOT EDIT IT.
|
||||
//
|
||||
|
@ -166,8 +167,12 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
/// DO NOT EDIT THIS FILE!
|
||||
/// </summary>
|
||||
[
|
||||
<xsl:if test="$layout-name">
|
||||
Layout("<xsl:value-of select="$layout-name"/>"),
|
||||
Rescue("<xsl:value-of select="$rescue-name"/>"),
|
||||
</xsl:if>
|
||||
<xsl:if test="$rescue-name">
|
||||
Rescue("<xsl:value-of select="$rescue-name"/>"),
|
||||
</xsl:if>
|
||||
ControllerDetails("<xsl:value-of select="@name"/>", Area = "<xsl:value-of select="$area-name"/>"),
|
||||
Helper(typeof(<xsl:value-of select="concat( @name, 'FieldHelper')"/>), "<xsl:value-of select="concat( @name, 'FieldHelper')"/>")
|
||||
]
|
||||
|
@ -196,7 +201,35 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
}
|
||||
}
|
||||
|
||||
<xsl:if test="adl:form">
|
||||
<xsl:if test="adl:property[@type='message']">
|
||||
/// <summary>
|
||||
/// Temporary hack to sort a problem with uninitialised messages
|
||||
/// </summary>
|
||||
public void fixupMessages() {
|
||||
ISession hibernator =
|
||||
NHibernateHelper.GetCurrentSession( <xsl:if test="$authentication-layer = 'Database'">Session[ NHibernateHelper.USERTOKEN],
|
||||
Session[NHibernateHelper.PASSTOKEN]</xsl:if>);
|
||||
ICollection<<xsl:value-of select="concat($entityns, '.', @name)"/>> instances =
|
||||
hibernator.CreateCriteria( typeof( <xsl:value-of select="concat($entityns, '.', @name)"/>))
|
||||
.List<<xsl:value-of select="concat($entityns, '.', @name)"/>>();
|
||||
|
||||
foreach ( <xsl:value-of select="concat($entityns, '.', @name)"/> instance in instances) {
|
||||
<xsl:for-each select="adl:property[@type='message']">
|
||||
if ( <xsl:value-of select="concat( 'instance.', @name)"/> == null || <xsl:value-of select="concat( 'instance.', @name, '.MessageId')"/> == 0 ){
|
||||
<xsl:value-of select="concat( 'instance.', @name)"/> = new Message();
|
||||
hibernator.Save( <xsl:value-of select="concat( 'instance.', @name)"/>);
|
||||
}
|
||||
</xsl:for-each>
|
||||
hibernator.Save( instance);
|
||||
}
|
||||
hibernator.Flush();
|
||||
<xsl:if test="adl:list[@name='list']">
|
||||
list();
|
||||
</xsl:if>
|
||||
}
|
||||
</xsl:if>
|
||||
|
||||
<xsl:if test="adl:form">
|
||||
<!-- unless there's at least one form, we won't generate a 'store' method -->
|
||||
/// <summary>
|
||||
/// Store the record represented by the parameters passed in an HTTP service
|
||||
|
@ -960,23 +993,25 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
/* form menus */
|
||||
<xsl:for-each select="$form//adl:field">
|
||||
<xsl:variable name="propname" select="@property"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="parent::adl:auxlist"/>
|
||||
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='entity']">
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the select for <xsl:value-of select="$propname"/> */
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the select for <xsl:value-of select="$propname"/> */
|
||||
<xsl:call-template name="menu">
|
||||
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='link']">
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the LHS of the shuffle for <xsl:value-of select="$propname"/> */
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the LHS of the shuffle for <xsl:value-of select="$propname"/> */
|
||||
<xsl:call-template name="menu">
|
||||
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:when test="$form/ancestor::adl:entity/adl:property[@name=$propname and @type='list']">
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the multi-select for <xsl:value-of select="@name"/> */
|
||||
/* produce a list of <xsl:value-of select="$form/ancestor::adl:entity/adl:property[@name=$propname]/@entity"/> to populate the multi-select for <xsl:value-of select="@name"/> */
|
||||
<xsl:call-template name="menu">
|
||||
<xsl:with-param name="property" select="$form/ancestor::adl:entity/adl:property[@name=$propname]"/>
|
||||
</xsl:call-template>
|
||||
|
@ -1026,7 +1061,7 @@ namespace <xsl:value-of select="$controllerns"/> {
|
|||
<xsl:template name="menu">
|
||||
<xsl:param name="property"/>
|
||||
<xsl:variable name="entity" select="//adl:entity[@name=$property/@entity]"/>
|
||||
<xsl:value-of select="concat('all_', $property/@name)"/> =
|
||||
<xsl:value-of select="concat('all_', $property/@name)"/> =
|
||||
<xsl:value-of select="concat( 'FetchAll', $entity/@name)"/>( NHibernateHelper.GetCurrentSession()),
|
||||
</xsl:template>
|
||||
|
||||
|
|
|
@ -8,91 +8,60 @@
|
|||
Transform ADL into entity classes
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.13 $
|
||||
$Date: 2008-05-09 16:12:12 $
|
||||
$Revision: 1.14 $
|
||||
$Date: 2008-05-21 13:00:56 $
|
||||
-->
|
||||
|
||||
<!-- 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"
|
||||
<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">
|
||||
|
||||
<xsl:include href="csharp-type-include.xslt"/>
|
||||
<xsl:include href="csharp-type-include.xslt"/>
|
||||
|
||||
<xsl:output encoding="UTF-8" method="text"/>
|
||||
<xsl:output encoding="UTF-8" method="text"/>
|
||||
|
||||
<!-- The locale for which these entities are generated
|
||||
<!-- 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-UK"/>
|
||||
<xsl:param name="locale" select="en-UK"/>
|
||||
|
||||
<!--
|
||||
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"/>
|
||||
<!-- The C# namespace within which I shall generate controllers -->
|
||||
<xsl:param name="controllerns" select="Unset"/>
|
||||
|
||||
<!-- 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 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'"/>
|
||||
|
||||
<xsl:template match="adl:application">
|
||||
<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:application">
|
||||
<xsl:apply-templates select="adl:entity"/>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="adl:entity">
|
||||
<!-- what's all this about? the objective is to get the revision number of the
|
||||
transform into the output, /without/ getting that revision number overwritten
|
||||
with the revision number of the generated file if the generated file is
|
||||
stored to CVS -->
|
||||
<!-- Don't bother generating anything for foreign entities -->
|
||||
<xsl:template match="adl:entity[@foreign='true']"/>
|
||||
|
||||
<xsl:variable name="transform-rev1"
|
||||
select="substring( '$Revision: 1.13 $', 11)"/>
|
||||
<xsl:variable name="transform-revision"
|
||||
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
|
||||
|
||||
<xsl:variable name="keyfield">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$abstract-key-name-convention='Name'">
|
||||
<xsl:value-of select="@name"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'NameId'">
|
||||
<xsl:value-of select="concat( @name, 'Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:when test="$abstract-key-name-convention = 'Name_Id'">
|
||||
<xsl:value-of select="concat( @name, '_Id')"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="'Id'"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
|
||||
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
|
||||
<xsl:template match="adl:entity">
|
||||
|
||||
/* ---- [ cut here: next file '<xsl:value-of select="@name"/>.auto.cs'] ---------------- */
|
||||
|
||||
//-------------------------------------------------------------
|
||||
//
|
||||
// Application Description Language framework
|
||||
// <xsl:value-of select="$product-version"/>
|
||||
// <xsl:value-of select="@name"/>.auto.cs
|
||||
//
|
||||
// (c)2007 Cygnet Solutions Ltd
|
||||
//
|
||||
// Automatically generated from application description using
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="$transform-revision"/>
|
||||
// adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.14 $', 10)"/>
|
||||
//
|
||||
// This file is automatically generated; DO NOT EDIT IT.
|
||||
//
|
||||
|
@ -114,7 +83,7 @@
|
|||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Automatically generated from description of entity <xsl:value-of select="@name"/>
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="$transform-revision"/>.
|
||||
/// using adl2entityclass.xsl revision <xsl:value-of select="substring( '$Revision: 1.14 $', 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.
|
||||
///
|
||||
|
@ -152,7 +121,8 @@
|
|||
<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>
|
||||
|
@ -160,40 +130,10 @@
|
|||
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
/// <summary>
|
||||
/// Auto-generated one-arg constructor; initialises Id slot and also all
|
||||
/// one-to-many slots
|
||||
/// </summary>
|
||||
public <xsl:value-of select="@name"/>( int key)
|
||||
{
|
||||
<xsl:call-template name="initialise-lists"/>
|
||||
|
||||
<xsl:value-of select="concat( ' _', $keyfield)"/> = key;
|
||||
}
|
||||
/// <summary>
|
||||
/// Auto-generated iv for Id (abstract primary key) slot
|
||||
/// </summary>
|
||||
private int <xsl:value-of select="concat( ' _', $keyfield)"/> = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated property for Id (abstract primary key) slot
|
||||
/// </summary>
|
||||
public virtual int <xsl:value-of select="$keyfield"/>
|
||||
{
|
||||
get { return <xsl:value-of select="concat( ' _', $keyfield)"/>; }
|
||||
set { <xsl:value-of select="concat( ' _', $keyfield)"/> = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Auto-generated overridden property for the Key slot, maps onto
|
||||
/// <xsl:value-of select="concat( ' _', $keyfield)"/>
|
||||
/// </summary>
|
||||
[Obsolete]
|
||||
public override int Key
|
||||
{
|
||||
get { return <xsl:value-of select="concat( ' _', $keyfield)"/>; }
|
||||
}
|
||||
|
||||
<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>
|
||||
/// <summary>
|
||||
|
@ -282,6 +222,7 @@
|
|||
<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 && <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);
|
||||
|
@ -490,24 +431,28 @@
|
|||
</xsl:if>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="initialise-lists">
|
||||
<!-- initialise all cocrete lists and links -->
|
||||
<xsl:for-each select="property[@type='list']">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@concrete='false'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( ' _', @name)"/> = new HashedSet<<xsl:value-of select="@entity"/>>();
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="property[@type='link']">
|
||||
<xsl:choose>
|
||||
<xsl:when test="@concrete='false'"/>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="concat( ' _', @name)"/> = new HashedSet<<xsl:value-of select="@entity"/>>();
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</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 HashedSet<<xsl:value-of select="@entity"/>>();
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
File diff suppressed because it is too large
Load diff
|
@ -12,7 +12,7 @@
|
|||
Convert ADL to MS-SQL
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.12 $
|
||||
$Revision: 1.13 $
|
||||
-->
|
||||
|
||||
<xsl:output indent="no" encoding="UTF-8" method="text"/>
|
||||
|
@ -27,70 +27,72 @@
|
|||
-->
|
||||
<xsl:param name="abstract-key-name-convention" select="Id"/>
|
||||
<xsl:param name="database"/>
|
||||
<!-- the name and version of the product being built -->
|
||||
<xsl:param name="product-version" select="'Application Description Language Framework'"/>
|
||||
|
||||
<!-- define upper and lower case letters to enable case conversion -->
|
||||
<!-- define upper and lower case letters to enable case conversion -->
|
||||
<xsl:variable name="ucase">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>
|
||||
<xsl:variable name="lcase">abcdefghijklmnopqrstuvwxyz</xsl:variable>
|
||||
<!-- define SQL keywords to police these out of field names -->
|
||||
<xsl:variable name="sqlkeywords-multiline">
|
||||
ADD EXCEPT PERCENT
|
||||
ALL EXEC PLAN
|
||||
ALTER EXECUTE PRECISION
|
||||
AND EXISTS PRIMARY
|
||||
ANY EXIT PRINT
|
||||
AS FETCH PROC
|
||||
ASC FILE PROCEDURE
|
||||
AUTHORIZATION FILLFACTOR PUBLIC
|
||||
BACKUP FOR RAISERROR
|
||||
BEGIN FOREIGN READ
|
||||
BETWEEN FREETEXT READTEXT
|
||||
BREAK FREETEXTTABLE RECONFIGURE
|
||||
BROWSE FROM REFERENCES
|
||||
BULK FULL REPLICATION
|
||||
BY FUNCTION RESTORE
|
||||
CASCADE GOTO RESTRICT
|
||||
CASE GRANT RETURN
|
||||
CHECK GROUP REVOKE
|
||||
CHECKPOINT HAVING RIGHT
|
||||
CLOSE HOLDLOCK ROLLBACK
|
||||
CLUSTERED IDENTITY ROWCOUNT
|
||||
COALESCE IDENTITY_INSERT ROWGUIDCOL
|
||||
COLLATE IDENTITYCOL RULE
|
||||
COLUMN IF SAVE
|
||||
COMMIT IN SCHEMA
|
||||
COMPUTE INDEX SELECT
|
||||
CONSTRAINT INNER SESSION_USER
|
||||
CONTAINS INSERT SET
|
||||
CONTAINSTABLE INTERSECT SETUSER
|
||||
CONTINUE INTO SHUTDOWN
|
||||
CONVERT IS SOME
|
||||
CREATE JOIN STATISTICS
|
||||
CROSS KEY SYSTEM_USER
|
||||
CURRENT KILL TABLE
|
||||
CURRENT_DATE LEFT TEXTSIZE
|
||||
CURRENT_TIME LIKE THEN
|
||||
CURRENT_TIMESTAMP LINENO TO
|
||||
CURRENT_USER LOAD TOP
|
||||
CURSOR NATIONAL TRAN
|
||||
DATABASE NOCHECK TRANSACTION
|
||||
DBCC NONCLUSTERED TRIGGER
|
||||
DEALLOCATE NOT TRUNCATE
|
||||
DECLARE NULL TSEQUAL
|
||||
DEFAULT NULLIF UNION
|
||||
DELETE OF UNIQUE
|
||||
DENY OFF UPDATE
|
||||
DESC OFFSETS UPDATETEXT
|
||||
DISK ON USE
|
||||
DISTINCT OPEN USER
|
||||
DISTRIBUTED OPENDATASOURCE VALUES
|
||||
DOUBLE OPENQUERY VARYING
|
||||
DROP OPENROWSET VIEW
|
||||
DUMMY OPENXML WAITFOR
|
||||
DUMP OPTION WHEN
|
||||
ELSE OR WHERE
|
||||
END ORDER WHILE
|
||||
ERRLVL OUTER WITH
|
||||
ESCAPE OVER WRITETEXT
|
||||
ADD EXCEPT PERCENT
|
||||
ALL EXEC PLAN
|
||||
ALTER EXECUTE PRECISION
|
||||
AND EXISTS PRIMARY
|
||||
ANY EXIT PRINT
|
||||
AS FETCH PROC
|
||||
ASC FILE PROCEDURE
|
||||
AUTHORIZATION FILLFACTOR PUBLIC
|
||||
BACKUP FOR RAISERROR
|
||||
BEGIN FOREIGN READ
|
||||
BETWEEN FREETEXT READTEXT
|
||||
BREAK FREETEXTTABLE RECONFIGURE
|
||||
BROWSE FROM REFERENCES
|
||||
BULK FULL REPLICATION
|
||||
BY FUNCTION RESTORE
|
||||
CASCADE GOTO RESTRICT
|
||||
CASE GRANT RETURN
|
||||
CHECK GROUP REVOKE
|
||||
CHECKPOINT HAVING RIGHT
|
||||
CLOSE HOLDLOCK ROLLBACK
|
||||
CLUSTERED IDENTITY ROWCOUNT
|
||||
COALESCE IDENTITY_INSERT ROWGUIDCOL
|
||||
COLLATE IDENTITYCOL RULE
|
||||
COLUMN IF SAVE
|
||||
COMMIT IN SCHEMA
|
||||
COMPUTE INDEX SELECT
|
||||
CONSTRAINT INNER SESSION_USER
|
||||
CONTAINS INSERT SET
|
||||
CONTAINSTABLE INTERSECT SETUSER
|
||||
CONTINUE INTO SHUTDOWN
|
||||
CONVERT IS SOME
|
||||
CREATE JOIN STATISTICS
|
||||
CROSS KEY SYSTEM_USER
|
||||
CURRENT KILL TABLE
|
||||
CURRENT_DATE LEFT TEXTSIZE
|
||||
CURRENT_TIME LIKE THEN
|
||||
CURRENT_TIMESTAMP LINENO TO
|
||||
CURRENT_USER LOAD TOP
|
||||
CURSOR NATIONAL TRAN
|
||||
DATABASE NOCHECK TRANSACTION
|
||||
DBCC NONCLUSTERED TRIGGER
|
||||
DEALLOCATE NOT TRUNCATE
|
||||
DECLARE NULL TSEQUAL
|
||||
DEFAULT NULLIF UNION
|
||||
DELETE OF UNIQUE
|
||||
DENY OFF UPDATE
|
||||
DESC OFFSETS UPDATETEXT
|
||||
DISK ON USE
|
||||
DISTINCT OPEN USER
|
||||
DISTRIBUTED OPENDATASOURCE VALUES
|
||||
DOUBLE OPENQUERY VARYING
|
||||
DROP OPENROWSET VIEW
|
||||
DUMMY OPENXML WAITFOR
|
||||
DUMP OPTION WHEN
|
||||
ELSE OR WHERE
|
||||
END ORDER WHILE
|
||||
ERRLVL OUTER WITH
|
||||
ESCAPE OVER WRITETEXT
|
||||
</xsl:variable>
|
||||
<xsl:variable name="sqlkeywords" select="concat(' ', normalize-space($sqlkeywords-multiline), ' ')"/>
|
||||
|
||||
|
@ -98,10 +100,10 @@
|
|||
<xsl:template match="adl:application">
|
||||
-------------------------------------------------------------------------------------------------
|
||||
--
|
||||
-- Application Description Language framework
|
||||
-- <xsl:value-of select="$product-version"/>
|
||||
--
|
||||
-- Database for application <xsl:value-of select="@name"/> version <xsl:value-of select="@version"/>
|
||||
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.12 $', 12)"/>
|
||||
-- Generated for MS-SQL 2000+ using adl2mssql.xslt <xsl:value-of select="substring('$Revision: 1.13 $', 12)"/>
|
||||
--
|
||||
-- Code generator (c) 2007 Cygnet Solutions Ltd
|
||||
--
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue