From 78964a814ec328e7baf890bd99784604595cf9e4 Mon Sep 17 00:00:00 2001
From: sb <sb>
Date: Wed, 28 Jan 2009 18:03:42 +0000
Subject: [PATCH] A number of minor bugfixes whilst getting SRU Hospitality to
 work with current ADL. I'm confident these are all bugfixes and they will
 have no adverse effect on other cutomers systems (the only system that might
 be affected is ASL and I shall check this).

---
 ADL.sln                                       |  13 +-
 .../UnitTests.csproj.FileListAbsolute.txt     |   5 +
 transforms/adl2canonical.xslt                 |  28 ++-
 transforms/adl2views.xslt                     | 185 ++++++++----------
 4 files changed, 118 insertions(+), 113 deletions(-)

diff --git a/ADL.sln b/ADL.sln
index 950d371..a829b97 100755
--- a/ADL.sln
+++ b/ADL.sln
@@ -7,7 +7,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CygnetToolkit", "..\CygnetT
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApp", "TestApp\TestApp.csproj", "{45578889-14A2-4A53-8391-0596369CCBA5}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{535E325C-7823-497E-A990-E3331C64681F}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{D705F7CA-EB87-48EF-8F18-7D1AD90660BA}"
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{83B41EED-23C8-4DEF-B113-46A426346E45}"
 	ProjectSection(SolutionItems) = preProject
@@ -16,9 +16,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 	EndProjectSection
 EndProject
 Global
-	GlobalSection(TestCaseManagementSettings) = postSolution
-		CategoryFile = ADL.vsmdi
-	EndGlobalSection
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
 		Release|Any CPU = Release|Any CPU
@@ -36,10 +33,10 @@ Global
 		{45578889-14A2-4A53-8391-0596369CCBA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{45578889-14A2-4A53-8391-0596369CCBA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{45578889-14A2-4A53-8391-0596369CCBA5}.Release|Any CPU.Build.0 = Release|Any CPU
-		{535E325C-7823-497E-A990-E3331C64681F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{535E325C-7823-497E-A990-E3331C64681F}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{535E325C-7823-497E-A990-E3331C64681F}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{535E325C-7823-497E-A990-E3331C64681F}.Release|Any CPU.Build.0 = Release|Any CPU
+		{D705F7CA-EB87-48EF-8F18-7D1AD90660BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{D705F7CA-EB87-48EF-8F18-7D1AD90660BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{D705F7CA-EB87-48EF-8F18-7D1AD90660BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{D705F7CA-EB87-48EF-8F18-7D1AD90660BA}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/UnitTests/obj/Debug/UnitTests.csproj.FileListAbsolute.txt b/UnitTests/obj/Debug/UnitTests.csproj.FileListAbsolute.txt
index b25fed6..4291642 100755
--- a/UnitTests/obj/Debug/UnitTests.csproj.FileListAbsolute.txt
+++ b/UnitTests/obj/Debug/UnitTests.csproj.FileListAbsolute.txt
@@ -3,3 +3,8 @@ C:\Projects\UnitTests\bin\Debug\UnitTests.pdb
 C:\Projects\UnitTests\obj\Debug\ResolveAssemblyReference.cache
 C:\Projects\UnitTests\obj\Debug\UnitTests.exe
 C:\Projects\UnitTests\obj\Debug\UnitTests.pdb
+C:\Projects\ADL\UnitTests\bin\Debug\UnitTests.exe
+C:\Projects\ADL\UnitTests\bin\Debug\UnitTests.pdb
+C:\Projects\ADL\UnitTests\obj\Debug\ResolveAssemblyReference.cache
+C:\Projects\ADL\UnitTests\obj\Debug\UnitTests.exe
+C:\Projects\ADL\UnitTests\obj\Debug\UnitTests.pdb
diff --git a/transforms/adl2canonical.xslt b/transforms/adl2canonical.xslt
index 1178e39..4069d74 100755
--- a/transforms/adl2canonical.xslt
+++ b/transforms/adl2canonical.xslt
@@ -20,8 +20,8 @@
       explicitly state the permission, even if it is 'none'.
     
     $Author: sb $
-    $Revision: 1.5 $
-    $Date: 2008-10-02 10:52:40 $
+    $Revision: 1.6 $
+    $Date: 2009-01-28 18:03:43 $
   -->
 
 <xsl:stylesheet version="1.0"
@@ -74,7 +74,7 @@
     *	THIS FILE IS AUTOMATICALLY GENERATED AND SHOULD NOT
     *	BE MANUALLY EDITED.
     *
-    *   Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.5 $', 12)"/>
+    *   Generated using adl2canonical.xslt <xsl:value-of select="substring('$Revision: 1.6 $', 12)"/>
 	*
 	***************************************************************************
 			</xsl:comment>
@@ -258,7 +258,7 @@
 			<!-- 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:call-template name="unroll-properties-no-lists"/>
 			<xsl:apply-templates select="adl:head|adl:top|adl:foot|adl:field|
                            adl:fieldgroup|adl:auxlist|adl:verb|
                            adl:permission|adl:pragma"/>
@@ -414,6 +414,26 @@
 		</xsl:for-each>
 	</xsl:template>
 
+	<!-- unroll all the explicit properties in the ancestor entity of 
+  the context (assumed to be form, page or list) into a list of fields, ommitting
+  those properties which are inherently lists -->
+	<xsl:template name="unroll-properties-no-lists">
+		<xsl:for-each select="ancestor::adl:entity/descendant::adl:property">
+			<xsl:choose>
+				<xsl:when test="@type='list'"/>
+				<xsl:when test="@type='link'"/>
+				<xsl:otherwise>
+					<field>
+						<xsl:attribute name="property">
+							<xsl:value-of select="@name"/>
+						</xsl:attribute>
+					</field>
+				</xsl:otherwise>
+			</xsl:choose>
+		</xsl:for-each>
+	</xsl:template>
+
+
 	<!-- 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
diff --git a/transforms/adl2views.xslt b/transforms/adl2views.xslt
index 7c42aef..116c103 100755
--- a/transforms/adl2views.xslt
+++ b/transforms/adl2views.xslt
@@ -13,8 +13,8 @@
     Transform ADL into velocity view templates
     
     $Author: sb $
-    $Revision: 1.17 $
-    $Date: 2009-01-28 12:10:02 $
+    $Revision: 1.18 $
+    $Date: 2009-01-28 18:03:43 $
 	-->
 	<!-- WARNING WARNING WARNING: Do NOT reformat this file! 
 		Whitespace (or lack of it) is significant! -->
@@ -124,7 +124,7 @@
 			Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
 			generated from ADL.
 
-			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 		</xsl:comment>
 		<xsl:call-template name="maybe-delete">
 			<xsl:with-param name="entity" select="."/>
@@ -161,7 +161,7 @@
 						Auto generated Velocity maybe-delete form for <xsl:value-of select="@name"/>,
 						generated from ADL.
 
-						Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+						Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 
 						<xsl:value-of select="/adl:application/@revision"/>
 					</xsl:comment>
@@ -244,7 +244,7 @@
 			Auto generated Velocity <xsl:value-of select="@name"/> form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
 			generated from ADL.
 
-			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 
 			<xsl:value-of select="/adl:application/@revision"/>
 		</xsl:comment>
@@ -366,7 +366,7 @@
 					Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
 					generated from ADL.
 
-					Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+					Generated using adl2views.xsl <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 
 					<xsl:value-of select="/adl:application/@revision"/>
 				</xsl:comment>
@@ -624,7 +624,7 @@
 
 			<xsl:choose>
 				<xsl:when test="@properties='listed'">
-					<xsl:comment>auxlist for with listed fields</xsl:comment>
+					<xsl:comment>auxlist for with listed fields: <xsl:value-of select="$farent/@name"/></xsl:comment>
 					<xsl:call-template name="internal-with-fields-list">
 						<xsl:with-param name="entity" select="//adl:entity[@name=$farent]"/>
 						<xsl:with-param name="fields" select="adl:field"/>
@@ -632,7 +632,7 @@
 					</xsl:call-template>
 				</xsl:when>
 				<xsl:otherwise>
-					<xsl:comment>auxlist with computed fields</xsl:comment>
+					<xsl:comment>auxlist with computed fields: <xsl:value-of select="$farent/@name"/></xsl:comment>
 					<xsl:call-template name="internal-with-properties-list">
 						<xsl:with-param name="entity" select="//adl:entity[@name=$farent]"/>
 						<xsl:with-param name="properties" select="//adl:entity[@name=$farent]//adl:property[(@distinct='user' or @distinct='all') and not( @type='link' or @type='list')]"/>
@@ -972,7 +972,7 @@
 			Auto generated Velocity list for <xsl:value-of select="@name"/>,
 			generated from ADL.
 
-			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+			Generated using adl2views.xslt <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 		</xsl:comment>
 
 		#capturefor( title)
@@ -1010,7 +1010,7 @@
 					  Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
 					  generated from ADL.
 
-					  Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.17 $', 10)"/>
+					  Generated using adl2listview.xsl <xsl:value-of select="substring( '$Revision: 1.18 $', 10)"/>
 				  </xsl:comment>
 				  <xsl:call-template name="install-scripts"/>
 			  </head>
@@ -1093,21 +1093,15 @@
 		  <table>
 			  <tr>
 				  <xsl:for-each select="$fields">
-					  <xsl:choose>
-						  <xsl:when test="@type='list'">
-							  <!-- suppress layout of columns which are themselves lists -->
-						  </xsl:when>
-						  <xsl:otherwise>
-							  <th>
-								  <xsl:call-template name="showprompt">
-									  <xsl:with-param name="node" select="."/>
-									  <xsl:with-param name="fallback" select="@property"/>
-									  <xsl:with-param name="entity" select="$entity"/>
-									  <xsl:with-param name="locale" select="$locale"/>
-								  </xsl:call-template>
-							  </th>
-						  </xsl:otherwise>
-					  </xsl:choose>
+					  <xsl:variable name="field" select="."/>
+					  <th>
+						  <xsl:call-template name="showprompt">
+						  <xsl:with-param name="node" select="."/>
+						  <xsl:with-param name="fallback" select="@property"/>
+						  <xsl:with-param name="entity" select="$entity"/>
+						  <xsl:with-param name="locale" select="$locale"/>
+						  </xsl:call-template>
+					  </th>
 				  </xsl:for-each>
 				  <xsl:for-each select="$entity/adl:form">
 					  <th>-</th>
@@ -1116,52 +1110,49 @@
 			  <xsl:if test="$can-search = 'true'">
 				  <tr class="search">
 					  <xsl:for-each select="$fields">
-						  <xsl:choose>
-							  <xsl:when test="@type='list'">
-								  <!-- suppress layout of columns which are themselves lists -->
-							  </xsl:when>
-							  <xsl:otherwise>
-								  <td class="search">
-									  <xsl:variable name="pname" select="@property"/>
-									  <xsl:variable name="property" select="$entity//adl:property[@name=$pname]"/>
-									  <xsl:variable name="size">
+						  <xsl:variable name="field" select="."/>
+						  <td class="search">
+							  <xsl:variable name="size">
+								  <xsl:choose>
+									  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='string'">
 										  <xsl:choose>
-											  <xsl:when test="$property/@type='string'">
-												  <xsl:choose>
-													  <xsl:when test="$property/@size &gt; 20">20</xsl:when>
-													  <xsl:otherwise>
-														  <xsl:value-of select="$property/@size"/>
-													  </xsl:otherwise>
-												  </xsl:choose>
-											  </xsl:when>
-											  <xsl:when test="$property/@type='integer'">8</xsl:when>
-											  <xsl:when test="$property/@type='real'">8</xsl:when>
-											  <xsl:when test="$property/@type='money'">8</xsl:when>
-											  <!-- xsl:when test="$property/@type='message'">20</xsl:when doesn't work yet -->
-											  <xsl:when test="$property/@type='text'">20</xsl:when>
-											  <!-- xsl:when test="$property/@type='enity'">20</xsl:when doesn't work yet -->
-											  <xsl:otherwise>0</xsl:otherwise>
+											  <xsl:when test="$entity//adl:property[@name=$field/@property]/@size &gt; 20">20</xsl:when>
+											  <xsl:otherwise>
+												  <xsl:value-of select="$entity//adl:property[@name=$field/@property]/@size"/>
+											  </xsl:otherwise>
 										  </xsl:choose>
-									  </xsl:variable>
-									  <xsl:if test="$size != 0">
-										  <input>
-											  <xsl:attribute name="name">
-												  <xsl:value-of select="concat('search_',$property/@name)"/>
-											  </xsl:attribute>
-											  <xsl:attribute name="size">
-												  <xsl:value-of select="$size"/>
-											  </xsl:attribute>
-											  <xsl:attribute name="value">
-												  <xsl:value-of select="concat( '$!search_', $property/@name)"/>
-											  </xsl:attribute>
-										  </input>
-									  </xsl:if>
-								  </td>
-							  </xsl:otherwise>
-						  </xsl:choose>
+									  </xsl:when>
+									  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='integer'">8</xsl:when>
+									  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='real'">8</xsl:when>
+									  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='money'">8</xsl:when>
+									  <!-- xsl:when test="$entity//adl:property[@name=$field/@property]/@type='message'">20</xsl:when doesn't work yet -->
+									  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='text'">20</xsl:when>
+									  <!-- xsl:when test="$entity//adl:property[@name=$field/@property]/@type='enity'">20</xsl:when doesn't work yet -->
+									  <xsl:otherwise>0</xsl:otherwise>
+								  </xsl:choose>
+							  </xsl:variable>
+							  <xsl:if test="$size != 0">
+								  <input>
+									  <xsl:attribute name="name">
+										  <xsl:value-of select="concat('search_',$entity//adl:property[@name=$field/@property]/@name)"/>
+									  </xsl:attribute>
+									  <xsl:attribute name="size">
+										  <xsl:value-of select="$size"/>
+									  </xsl:attribute>
+									  <xsl:attribute name="value">
+										  <xsl:value-of select="concat( '$!search_', $entity//adl:property[@name=$field/@property]/@name)"/>
+									  </xsl:attribute>
+								  </input>
+							  </xsl:if>
+						  </td>
 					  </xsl:for-each>
 				  </tr>
 			  </xsl:if>
+			  <xsl:if test="not( $entity/@name)">
+				  <xsl:message terminate="yes">
+					  Unknown entity whilst trying to generate list
+				  </xsl:message>
+			  </xsl:if>
 			  #foreach( <xsl:value-of select="concat( '$', $entity/@name)"/> in <xsl:value-of select="concat('$', $instance-list)"/>)
 			  #if ( $velocityCount % 2 == 0)
 			  #set( $oddity = "even")
@@ -1170,40 +1161,32 @@
 			  #end
 			  <tr class="$oddity">
 				  <xsl:for-each select="$fields">
-					  <xsl:variable name="pname" select="@property"/>
-					  <xsl:variable name="property" select="$entity//adl:property[@name=$pname]"/>
-					  <xsl:choose>
-						  <xsl:when test="@type='list'">
-							  <!-- suppress layout of columns which are themselves lists -->
-						  </xsl:when>
-						  <xsl:otherwise>
-							  <td>
-								  <xsl:choose>
-									  <xsl:when test="not( $property/@name)">
-										  <!-- shouldn't happen. There is definitely a bug here, because it does happen - but it shouldn't -->
-									  </xsl:when>
-									  <xsl:when test="$property/@type = 'date'">
-										  #if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
-										  <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>.ToString( 'd')
-										  #end
-									  </xsl:when>
-									  <xsl:when test="$property/@type='message'">
-										  #if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
-										  $t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
-										  #end
-									  </xsl:when>
-									  <xsl:when test="$property/@type='entity'">
-										  #if( <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name)"/>)
-										  <xsl:value-of select="concat( '$', $entity/@name, '.', $property/@name, '.UserIdentifier')"/>
-										  #end
-									  </xsl:when>
-									  <xsl:otherwise>
-										  <xsl:value-of select="concat( '$!', $entity/@name, '.', $property/@name)"/>
-									  </xsl:otherwise>
-								  </xsl:choose>
-							  </td>
-						  </xsl:otherwise>
-					  </xsl:choose>
+					  <xsl:variable name="field" select="."/>
+					  <td>
+						  <xsl:choose>
+							  <xsl:when test="not( $entity//adl:property[@name=$field/@property]/@name)">
+								  <!-- shouldn't happen. There is definitely a bug here, because it does happen - but it shouldn't -->
+							  </xsl:when>
+							  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type = 'date'">
+								  #if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
+								  <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>.ToString( 'd')
+								  #end
+							  </xsl:when>
+							  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='message'">
+								  #if ( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
+								  $t.Msg( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
+								  #end
+							  </xsl:when>
+							  <xsl:when test="$entity//adl:property[@name=$field/@property]/@type='entity'">
+								  #if( <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>)
+								  <xsl:value-of select="concat( '$', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name, '.UserIdentifier')"/>
+								  #end
+							  </xsl:when>
+							  <xsl:otherwise>
+								  <xsl:value-of select="concat( '$!', $entity/@name, '.', $entity//adl:property[@name=$field/@property]/@name)"/>
+							  </xsl:otherwise>
+						  </xsl:choose>
+					  </td>
 				  </xsl:for-each>
 				  <xsl:variable name="keys">
 					  <!-- assemble keys in a Velocity-friendly format, then splice it into
@@ -1231,7 +1214,7 @@
 					  <td>
 						  <a>
 							  <xsl:attribute name="href">
-								  <xsl:value-of select="concat( @name, '.rails', $keys)"/>
+								  <xsl:value-of select="concat( '../', $entity/@name, '/', @name, '.rails', $keys)"/>
 							  </xsl:attribute>
 							  <xsl:value-of select="@name"/>!
 						  </a>