Copied all the currently working transforms from 'transforms01' to 'transforms'; created new schema 'adl-0-1-0.xsd' which once tested should become the new
normative reference.
This commit is contained in:
parent
bf13d05877
commit
e2130bc4c4
20 changed files with 6161 additions and 3159 deletions
99
transforms/csharp-type-include.xslt
Executable file
99
transforms/csharp-type-include.xslt
Executable file
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!--
|
||||
Application Description Language framework
|
||||
csharp-type-include.xslt
|
||||
|
||||
(c) 2007 Cygnet Solutions Ltd
|
||||
|
||||
An XSL transform intended to be included into other XSL stylesheets,
|
||||
intended to keep lookup of the C# type from ADL properties in
|
||||
one place for ease of maintenance
|
||||
|
||||
$Author: sb $
|
||||
$Revision: 1.1 $
|
||||
$Date: 2008-05-29 16:40:09 $
|
||||
-->
|
||||
|
||||
<xsl:stylesheet version="1.0"
|
||||
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:include href="base-type-include.xslt"/>
|
||||
|
||||
<!-- return the primitive C# type of the property which is passed as
|
||||
a parameter - i.e. if csharp-type is an entity, then the csharp-type
|
||||
of the keyfield of that entity, and so on. -->
|
||||
<xsl:template name="csharp-base-type">
|
||||
<xsl:param name="property"/>
|
||||
<xsl:param name="entityns"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$property/@type = 'entity'">
|
||||
<xsl:variable name="entityname" select="$property/@entity"/>
|
||||
<xsl:choose>
|
||||
<xsl:when test="//adl:entity[@name=$entityname]/adl:key/adl:property">
|
||||
<!-- recurse... -->
|
||||
<xsl:call-template name="csharp-base-type">
|
||||
<xsl:with-param name="property"
|
||||
select="//adl:entity[@name=$entityname]/adl:key/adl:property[position()=1]"/>
|
||||
<xsl:with-param name="entityns" select="$entityns"/>
|
||||
</xsl:call-template>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:message terminate="yes">
|
||||
ADL: ERROR: could not find C# base type of property <xsl:value-of select="$property/@name"/>
|
||||
</xsl:message>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:call-template name="csharp-type">
|
||||
<xsl:with-param name="property" select="$property"/>
|
||||
<xsl:with-param name="entityns" select="$entityns"/>
|
||||
</xsl:call-template>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<!-- return the C# type of the property which is passed as a parameter -->
|
||||
<xsl:template name="csharp-type">
|
||||
<xsl:param name="property"/>
|
||||
<xsl:param name="entityns"/>
|
||||
<xsl:variable name="base-type">
|
||||
<xsl:call-template name="base-type">
|
||||
<xsl:with-param name="property" select="$property"/>
|
||||
</xsl:call-template>
|
||||
</xsl:variable>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$property/@type = 'message'">Message</xsl:when>
|
||||
<xsl:when test="$base-type = 'link'">
|
||||
ICollection<<xsl:value-of select="@entity"/>>
|
||||
</xsl:when>
|
||||
<xsl:when test="$base-type = 'list'">
|
||||
ICollection<<xsl:value-of select="@entity"/>>
|
||||
</xsl:when>
|
||||
<xsl:when test="$base-type = 'date'">DateTime</xsl:when>
|
||||
<xsl:when test="$base-type = 'time'">DateTime</xsl:when>
|
||||
<xsl:when test="$base-type = 'string'">String</xsl:when>
|
||||
<xsl:when test="$base-type = 'text'">String</xsl:when>
|
||||
<xsl:when test="$base-type = 'boolean'">Boolean</xsl:when>
|
||||
<xsl:when test="$base-type = 'timestamp'">DateTime</xsl:when>
|
||||
<xsl:when test="$base-type = 'integer'">int</xsl:when>
|
||||
<xsl:when test="$base-type = 'real'">double</xsl:when>
|
||||
<xsl:when test="$base-type = 'money'">Decimal</xsl:when>
|
||||
<xsl:when test="$base-type = 'entity'">
|
||||
<xsl:choose>
|
||||
<xsl:when test="$entityns">
|
||||
<xsl:value-of select="concat( $entityns, '.', $property/@entity)"/>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="$property/@entity"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>[unknown?]</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
</xsl:stylesheet>
|
||||
Loading…
Add table
Add a link
Reference in a new issue