Now with working (but very slow) user-editable internationalised messages

This commit is contained in:
sb 2008-02-27 17:38:41 +00:00
parent f28dae3038
commit 0cac7bfba9
7 changed files with 300 additions and 170 deletions

View file

@ -1,5 +1,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="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">
<!--
Application Description Language framework
adl2views.xsl
@ -9,8 +12,8 @@
Transform ADL into velocity view templates
$Author: sb $
$Revision: 1.4 $
$Date: 2008-02-21 12:40:23 $
$Revision: 1.5 $
$Date: 2008-02-27 17:38:41 $
-->
<!-- WARNING WARNING WARNING: Do NOT reformat this file!
Whitespace (or lack of it) is significant! -->
@ -24,6 +27,15 @@
TODO: we need to generate views for each available locale, but this is not
yet implemented. When it is we will almost certainly still need a 'default locale' -->
<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"/>
<!-- 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
@ -31,26 +43,26 @@
stored to CVS -->
<xsl:variable name="transform-rev1"
select="substring( '$Revision: 1.4 $', 11)"/>
select="substring( '$Revision: 1.5 $', 11)"/>
<xsl:variable name="transform-revision"
select="substring( $transform-rev1, 0, string-length( $transform-rev1) - 1)"/>
<xsl:template match="application">
<xsl:template match="adl:application">
<output>
<xsl:apply-templates select="entity"/>
<xsl:apply-templates select="adl:entity"/>
<!-- make sure extraneous junk doesn't get into the last file generated,
by putting it into a separate file -->
<xsl:comment> [ cut here: next file 'tail.txt' ] </xsl:comment>
</output>
</xsl:template>
<xsl:template match="entity[@foreign='true']"/>
<xsl:template match="adl:entity[@foreign='true']"/>
<!-- Don't bother generating anything for foreign entities -->
<xsl:template match="entity">
<xsl:apply-templates select="form"/>
<xsl:apply-templates select="list"/>
<xsl:template match="adl:entity">
<xsl:apply-templates select="adl:form"/>
<xsl:apply-templates select="adl:list"/>
<xsl:text>
</xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( @name, '/maybedelete.auto.vm')"/>' ] </xsl:comment>
@ -115,10 +127,10 @@
<!-- layout of forms -->
<xsl:template match="form">
<xsl:template match="adl:form">
<xsl:variable name="formname" select="@name"/>
<xsl:variable name="aoran">
<xsl:variable name="initial" select="substring( ancestor::entity/@name, 1, 1)"/>
<xsl:variable name="initial" select="substring( ancestor::adl:entity/@name, 1, 1)"/>
<xsl:choose>
<xsl:when test="$initial = 'A'">an</xsl:when>
<xsl:when test="$initial = 'E'">an</xsl:when>
@ -130,15 +142,15 @@
</xsl:variable>
<xsl:text>
</xsl:text>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( ancestor::entity/@name, '/', @name)"/>.auto.vm' ] </xsl:comment>
<xsl:comment> [ cut here: next file '<xsl:value-of select="concat( ancestor::adl:entity/@name, '/', @name)"/>.auto.vm' ] </xsl:comment>
<xsl:text>
</xsl:text>
<html>
<xsl:comment>
#if ( $instance)
#set( $title = "<xsl:value-of select="concat( 'Edit ', ' ', ancestor::entity/@name)"/> $instance.UserIdentifier")
#set( $title = "<xsl:value-of select="concat( 'Edit ', ' ', ancestor::adl:entity/@name)"/> $instance.UserIdentifier")
#else
#set( $title = "Add a new <xsl:value-of select="ancestor::entity/@name"/>")
#set( $title = "Add a new <xsl:value-of select="ancestor::adl:entity/@name"/>")
#end
</xsl:comment>
<head>
@ -146,7 +158,7 @@
<xsl:comment>
Application Description Language framework
Auto generated Velocity form for <xsl:value-of select="ancestor::entity/@name"/>,
Auto generated Velocity form for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2views.xsl <xsl:value-of select="$transform-revision"/>
@ -158,7 +170,7 @@
${FormHelper.InstallScripts()}
${Validation.InstallScripts()}
${Scriptaculous.InstallScripts()}
${DateTime.InstallScripts()}
${DateTimeHelper.InstallScripts()}
${ScriptsHelper.InstallScript( "Sitewide")}
${ScriptsHelper.InstallScript( "Behaviour")}
@ -187,8 +199,8 @@
<xsl:for-each select="//definition">
<xsl:variable name="errormsg">
<xsl:choose>
<xsl:when test="help[@locale=$locale]">
<xsl:apply-templates select="help[@locale=$locale]"/>
<xsl:when test="adl:help[@locale=$locale]">
<xsl:apply-templates select="adl:help[@locale=$locale]"/>
</xsl:when>
<xsl:otherwise>
Does not meet the format requirements for <xsl:value-of select="@name"/>
@ -220,7 +232,7 @@
<script type="text/javascript" language='JavaScript1.2' src="../script/panes.js"></script>
<style type="text/css">
<xsl:for-each select="../property[@required='true']">
<xsl:for-each select="../adl:property[@required='true']">
#<xsl:value-of select="concat( 'advice-required-instance_', @name)"/>
{
color: white;
@ -269,14 +281,14 @@
<xsl:value-of select="$formname"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="ancestor::entity/@natural-key">
<xsl:variable name="keyfield" select="ancestor::entity/@natural-key"/>
<xsl:when test="ancestor::adl:entity/@natural-key">
<xsl:variable name="keyfield" select="ancestor::adl:entity/@natural-key"/>
<xsl:choose>
<xsl:when test="@properties='all'">
<!-- no need to emit a hidden widget for the natural key, as there will be a
non-hidden one anyway -->
</xsl:when>
<xsl:when test="field[@name=$keyfield]">
<xsl:when test="adl:field[@name=$keyfield]">
<!-- no need to emit a hidden widget for the natural key, as there will be a
non-hidden one anyway -->
</xsl:when>
@ -289,12 +301,12 @@
<xsl:otherwise>
<!-- there isn't a natural primary key; create a hidden widget
for the abstract primary key -->
${FormHelper.HiddenField( "instance.<xsl:value-of select="ancestor::entity/@name"/>Id")}
${FormHelper.HiddenField( "instance.<xsl:value-of select="ancestor::adl:entity/@name"/>Id")}
</xsl:otherwise>
</xsl:choose>
<xsl:if test="fieldgroup">
<xsl:if test="adl:fieldgroup">
<div id="tabbar">
<xsl:for-each select="fieldgroup">
<xsl:for-each select="adl:fieldgroup">
<span class="tab">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, 'tab')"/>
@ -312,15 +324,15 @@
</xsl:for-each>
</div>
</xsl:if>
<xsl:apply-templates select="fieldgroup"/>
<xsl:apply-templates select="adl:fieldgroup"/>
<div class="pane">
<table>
<xsl:choose>
<xsl:when test="@properties='listed'">
<xsl:apply-templates select="field|auxlist|verb"/>
<xsl:apply-templates select="adl:field|adl:auxlist|adl:verb"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="ancestor::entity/property"/>
<xsl:apply-templates select="ancestor::adl:entity/adl:property"/>
</xsl:otherwise>
</xsl:choose>
<tr class="actionSafe">
@ -357,7 +369,7 @@
</html>
</xsl:template>
<xsl:template match="fieldgroup">
<xsl:template match="adl:fieldgroup">
<div class="pane">
<xsl:attribute name="id">
<xsl:value-of select="concat( @name, 'pane')"/>
@ -379,19 +391,19 @@
</h3>
</a>
<table>
<xsl:apply-templates select="field|verb|auxlist"/>
<xsl:apply-templates select="adl:field|adl:verb|adl:auxlist"/>
</table>
</div>
</xsl:template>
<xsl:template match="auxlist">
<xsl:template match="adl:auxlist">
<xsl:variable name="listprop" select="@property"/>
<xsl:variable name="farent" select="ancestor::entity/property[@name=$listprop]/@entity"/>
<xsl:variable name="nearent" select="ancestor::entity/@name"/>
<xsl:variable name="farid">
<xsl:choose>
<xsl:when test="//entity[@name=$farent]/@natural-key">
<xsl:value-of select="//entity[@name=$farent]/@natural-key"/>
<xsl:when test="//adl:entity[@name=$farent]/@natural-key">
<xsl:value-of select="//adl:entity[@name=$farent]/@natural-key"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $farent, 'Id')"/>
@ -399,12 +411,12 @@
</xsl:choose>
</xsl:variable>
<xsl:variable name="farkey">
<xsl:value-of select="//entity[@name=$farent]/property[@entity=$nearent]/@name"/>
<xsl:value-of select="//adl:entity[@name=$farent]/adl:property[@entity=$nearent]/@name"/>
</xsl:variable>
<xsl:variable name="nearkey">
<xsl:choose>
<xsl:when test="ancestor::entity[@natural-key]">
<xsl:value-of select="ancestor::entity[@natural-key]"/>
<xsl:when test="ancestor::adl:entity[@natural-key]">
<xsl:value-of select="ancestor::adl:entity[@natural-key]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat( $nearent, 'Id')"/>
@ -430,13 +442,13 @@
<xsl:choose>
<xsl:when test="@properties='listed'">
<tr>
<xsl:for-each select="field">
<xsl:for-each select="adl:field">
<xsl:variable name="fieldprop" select="@property"/>
<th>
<!-- Getting the prompt for the field from a property of another entity is a bit
complex... -->
<xsl:call-template name="showprompt">
<xsl:with-param name="node" select="//entity[@name=$farent]/property[@name=$fieldprop]"/>
<xsl:with-param name="node" select="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]"/>
<xsl:with-param name="fallback" select="@property"/>
</xsl:call-template>
</th>
@ -452,19 +464,19 @@
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="field">
<xsl:for-each select="adl:field">
<xsl:variable name="fieldprop" select="@property"/>
<td>
<xsl:choose>
<xsl:when test="//entity[@name=$farent]/property[@name=$fieldprop]/@type='entity'">
<xsl:when test="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/@type='entity'">
#if ( $item.<xsl:value-of select="@property"/>)
$item.<xsl:value-of select="@property"/>.UserIdentifier
#end
</xsl:when>
<xsl:when test="//entity[@name=$farent]/property[@name=$fieldprop]/option">
<xsl:when test="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/adl:option">
<!-- if we can get a prompt value for the option, it would be better to
show it than the raw value-->
<xsl:for-each select="//entity[@name=$farent]/property[@name=$fieldprop]/option">
<xsl:for-each select="//adl:entity[@name=$farent]/adl:property[@name=$fieldprop]/adl:option">
#if ( $item.<xsl:value-of select="$fieldprop"/> == '<xsl:value-of select="@value"/>')
<xsl:call-template name="showprompt">
<xsl:with-param name="fallback" select="@value"/>
@ -493,11 +505,11 @@
<!-- properties not listed, so therefore presumably all. TODO: This won't work, rewrite. Need to
find the entity of the property this auxlist depends on, and then interrogate that -->
<tr>
<xsl:for-each select="ancestor::entity/property[@distinct='user']">
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
<th>
<xsl:choose>
<xsl:when test="prompt[@locale=$locale]">
<xsl:value-of select="prompt[@locale=$locale]/@prompt"/>
<xsl:when test="adl:prompt[@locale=$locale]">
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
@ -514,7 +526,7 @@
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="ancestor::entity/property[@distinct='user']">
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
<td>
$!instance.<xsl:value-of select="@name"/>
</td>
@ -533,7 +545,7 @@
</xsl:choose>
</xsl:template>
<xsl:template match="verb">
<xsl:template match="adl:verb">
<xsl:variable name="class">
<xsl:choose>
<xsl:when test="@dangerous='true'">actionDangerous</xsl:when>
@ -546,7 +558,7 @@
<xsl:attribute name="class">
<xsl:value-of select="$class"/>
</xsl:attribute>
<xsl:apply-templates select="help[@locale = $locale]"/>
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
</td>
<td style="text-align:right">
<xsl:attribute name="class">
@ -564,14 +576,14 @@
</tr>
</xsl:template>
<xsl:template match="field">
<xsl:template match="adl:field">
<xsl:variable name="propname">
<xsl:value-of select="@property"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="ancestor::entity/property[@name=$propname]">
<xsl:when test="ancestor::adl:entity/adl:property[@name=$propname]">
<!-- there is a real property -->
<xsl:apply-templates select="ancestor::entity/property[@name=$propname]">
<xsl:apply-templates select="ancestor::adl:entity/adl:property[@name=$propname]">
<xsl:with-param name="oddness">
<xsl:choose>
<xsl:when test="position() mod 2 = 0">even</xsl:when>
@ -586,8 +598,34 @@
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="adl:property[@type='message']">
<!-- HIHGLY experimental - an internationalised message -->
<xsl:param name="oddness" select="odd"/>
<tr>
<xsl:attribute name="class">
<xsl:value-of select="$oddness"/>
</xsl:attribute>
<td class="label" title="To edit this text, select it">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:call-template name="showprompt">
<xsl:with-param name="fallback" select="@name"/>
</xsl:call-template>")}
</td>
<td class="widget" colspan="2">
<xsl:variable name="url">
$siteRoot/I18nMessage/edit.rails?Message_Id=<xsl:value-of select="concat( '$instance.', @name, '.MessageId')"/>
</xsl:variable>
<a target="_blank" class="i18nmessage">
<xsl:attribute name="href">
<xsl:value-of select="normalize-space( $url)"/>
</xsl:attribute>
<xsl:value-of select="concat( '$instance.', @name, '.LocalText')"/>
</a>
</td>
</tr>
</xsl:template>
<xsl:template match="property[@type='link']">
<xsl:template match="adl:property[@type='link']">
<!-- note! this template is only intended to match properties in the context of a form:
it may be we need to add a mode to indicate this! -->
<!-- for links we implement a shuffle widget, which extends over both columns -->
@ -639,13 +677,13 @@
</xsl:choose>
</xsl:attribute>
<td class="help" colspan="2">
<xsl:apply-templates select="help[@locale = $locale]"/>
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
</td>
</tr>
</xsl:template>
<xsl:template match="property[@type='text']">
<xsl:template match="adl:property[@type='text']">
<!-- note! this template is only intended to match properties in the context of a form:
it may be we need to add a mode to indicate this! -->
<!-- text box widgets, like shuffle widgets, extend over both columns -->
@ -666,8 +704,8 @@
</xsl:attribute>
<td class="label" rowspan="2">
${FormHelper.LabelFor( "instance.<xsl:value-of select="@name"/>", "<xsl:choose>
<xsl:when test="prompt[@locale = $locale]">
<xsl:apply-templates select="prompt[@locale = $locale]"/>
<xsl:when test="adl:prompt[@locale = $locale]">
<xsl:apply-templates select="adl:prompt[@locale = $locale]"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
@ -686,12 +724,12 @@
</xsl:choose>
</xsl:attribute>
<td class="help" colspan="2">
<xsl:apply-templates select="help[@locale = $locale]"/>
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
</td>
</tr>
</xsl:template>
<xsl:template match="property">
<xsl:template match="adl:property">
<xsl:param name="oddness" select="odd"/>
<!-- note! this template is only intended to match properties in the context of a form:
it may be we need to add a mode to indicate this! -->
@ -704,8 +742,8 @@
important! -->
<xsl:variable name="if-missing">
<xsl:choose>
<xsl:when test="if-missing[@locale = $locale]">
<xsl:value-of select="if-missing[@locale = $locale]"/>
<xsl:when test="adl:if-missing[@locale = $locale]">
<xsl:value-of select="adl:if-missing[@locale = $locale]"/>
</xsl:when>
<xsl:when test="@required='true'">
You must provide a value for <xsl:value-of select="@name"/>
@ -727,11 +765,11 @@
Helper class? -->
<xsl:variable name="permission">
<xsl:choose>
<xsl:when test="permission">
<xsl:value-of select="permission[position()=1]/@permission"/>
<xsl:when test="adl:permission">
<xsl:value-of select="adl:permission[position()=1]/@permission"/>
</xsl:when>
<xsl:when test="../permission">
<xsl:value-of select="../permission[position()=1]/@permission"/>
<xsl:when test="../adl:permission">
<xsl:value-of select="../adl:permission[position()=1]/@permission"/>
</xsl:when>
<xsl:otherwise>none</xsl:otherwise>
</xsl:choose>
@ -759,7 +797,7 @@
of UserIdentifiers
-->
<xsl:otherwise>
<xsl:value-of select="concat('$instance.', @name)"/>
<xsl:value-of select="concat('$!instance.', @name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
@ -770,14 +808,14 @@
<xsl:when test="@type='entity'">
<!-- a menu of the appropriate entity -->
#if ( $instance)
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='<xsl:value-of select="concat( @entity, 'Id')"/>', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#else
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='<xsl:value-of select="concat( @entity, 'Id')"/>', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{firstoption='[unset]', firstoptionvalue='-1', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
#end
</xsl:when>
<xsl:when test="@type='list'">
<!-- a multi-select menu of the appropriate entity -->
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{multiple='multiple', size='8', text='UserIdentifier', value='<xsl:value-of select="concat( @entity, 'Id')"/>', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
${FormHelper.Select( "instance.<xsl:value-of select="@name"/>", $instance.<xsl:value-of select="@name"/>, <xsl:value-of select="concat( '$all_', @name)"/>, "%{multiple='multiple', size='8', text='UserIdentifier', value='KeyString', title='<xsl:value-of select="normalize-space( $if-missing)"/>'}" )}
</xsl:when>
<xsl:when test="@type='defined'">
<!-- likely to be hardest of all... -->
@ -785,28 +823,28 @@
<xsl:value-of select="@definition"/>
</xsl:variable>
<xsl:variable name="maximum">
<xsl:value-of select="/application/definition[@name=$definition]/@maximum"/>
<xsl:value-of select="//adl:definition[@name=$definition]/@maximum"/>
</xsl:variable>
<xsl:variable name="minimum">
<xsl:value-of select="/application/definition[@name=$definition]/@minimum"/>
<xsl:value-of select="//adl:definition[@name=$definition]/@minimum"/>
</xsl:variable>
<xsl:variable name="validationpattern">
<xsl:value-of select="/application/definition[@name=$definition]/@pattern"/>
<xsl:value-of select="//adl:definition[@name=$definition]/@pattern"/>
</xsl:variable>
<xsl:variable name="definedtype">
<xsl:value-of select="/application/definition[@name=$definition]/@type"/>
<xsl:value-of select="//adl:definition[@name=$definition]/@type"/>
</xsl:variable>
<xsl:variable name="definedsize">
<xsl:value-of select="/application/definition[@name=$definition]/@size"/>
<xsl:value-of select="//adl:definition[@name=$definition]/@size"/>
</xsl:variable>
<input type="text">
<xsl:attribute name="class">
<xsl:if test="@required='true'">required </xsl:if>
<xsl:choose>
<xsl:when test="/application/definition[@name=$definition]/@pattern">
<xsl:when test="//adl:definition[@name=$definition]/@pattern">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
<xsl:when test="/application/definition[@name=$definition]/@minimum">
<xsl:when test="//adl:definition[@name=$definition]/@minimum">
<xsl:value-of select="concat( 'validate-custom-', $definition)"/>
</xsl:when>
<xsl:when test="$definedtype='integer'">validate-digits</xsl:when>
@ -886,13 +924,15 @@
<xsl:apply-templates select="option"/>
</select>
<script type="text/javascript" language="javascript">
#set ( <xsl:value-of select="concat( '$', @name, '_sel_opt')"/>="<xsl:value-of select="concat( @name, '-$instance.', @name)"/>")
// &lt;![CDATA[
#set ( <xsl:value-of select="concat( '$', @name, '_sel_opt')"/>="<xsl:value-of select="concat( @name, '-$instance.', @name)"/>")
option = document.getElementById( "<xsl:value-of select="concat( '$', @name, '_sel_opt')"/>");
if ( option != null)
{
option.selected = true;
}
// ]]&gt;
</script>
</xsl:when>
<xsl:when test="@type='boolean'">
@ -926,28 +966,28 @@
</xsl:choose>
</td>
<td class="help">
<xsl:apply-templates select="help[@locale = $locale]"/>
<xsl:apply-templates select="adl:help[@locale = $locale]"/>
</td>
</tr>
</xsl:template>
<xsl:template match="prompt">
<xsl:template match="adl:prompt">
<xsl:value-of select="@prompt"/>
</xsl:template>
<xsl:template match="help">
<xsl:template match="adl:help">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="option">
<xsl:template match="adl:option">
<option>
<xsl:attribute name="id"><xsl:value-of select="../@name"/>-<xsl:value-of select="@value"/></xsl:attribute>
<xsl:attribute name="value">
<xsl:value-of select="@value"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="prompt[@locale=$locale]">
<xsl:value-of select="prompt[@locale=$locale]/@prompt"/>
<xsl:when test="adl:prompt[@locale=$locale]">
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@value"/>
@ -958,7 +998,7 @@
<!-- layout of lists -->
<xsl:template match="list">
<xsl:template match="adl:list">
<xsl:variable name="action" select="@onselect"/>
<xsl:text>
</xsl:text>
@ -985,7 +1025,7 @@
#set( $title = "<xsl:value-of select="normalize-space( concat( 'List ', $withpluralsuffix))"/>")
<xsl:call-template name="head"/>
<xsl:comment>
Auto generated Velocity list for <xsl:value-of select="ancestor::entity/@name"/>,
Auto generated Velocity list for <xsl:value-of select="ancestor::adl:entity/@name"/>,
generated from ADL.
Generated using adl2listview.xsl <xsl:value-of select="$transform-revision"/>
@ -994,7 +1034,7 @@
${FormHelper.InstallScripts()}
${Validation.InstallScripts()}
${Scriptaculous.InstallScripts()}
${DateTime.InstallScripts()}
${DateTimeHelper.InstallScripts()}
${ScriptsHelper.InstallScript( "Behaviour")}
${ScriptsHelper.InstallScript( "Sitewide")}
@ -1027,7 +1067,7 @@
#if($instances.HasLast) $PaginationHelper.CreatePageLink( $instances.LastIndex, "&gt;&gt;" ) #end
#if(!$instances.HasLast) &gt;&gt; #end
</span>
<xsl:if test="../form">
<xsl:if test="../adl:form">
<span class="add">
<a>
<xsl:attribute name="href">
@ -1052,13 +1092,13 @@
<xsl:choose>
<xsl:when test="@properties='listed'">
<tr>
<xsl:for-each select="field">
<xsl:for-each select="adl:field">
<th>
<xsl:variable name="pname" select="@property"/>
<xsl:variable name="property" select="ancestor::entity/property[@name=$pname]"/>
<xsl:variable name="property" select="ancestor::adl:entity/adl:property[@name=$pname]"/>
<xsl:choose>
<xsl:when test="$property/prompt[@locale=$locale]">
<xsl:value-of select="$property/prompt[@locale=$locale]/@prompt"/>
<xsl:when test="$property/adl:prompt[@locale=$locale]">
<xsl:value-of select="$property/adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@property"/>
@ -1066,7 +1106,9 @@
</xsl:choose>
</th>
</xsl:for-each>
<th>-</th>
<xsl:for-each select="ancestor::adl:entity/adl:form">
<th>-</th>
</xsl:for-each>
</tr>
#foreach( $instance in $instances)
#if ( $velocityCount % 2 == 0)
@ -1075,39 +1117,62 @@
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="field">
<xsl:for-each select="adl:field">
<td>
<xsl:variable name="prop" select="@property"/>
<xsl:choose>
<xsl:when test="ancestor::entity/property[@name=$prop]/@type = 'date'">
<xsl:when test="ancestor::adl:entity/adl:property[@name=$prop]/@type = 'date'">
#if ( $instance.<xsl:value-of select="@property"/>)
$instance.<xsl:value-of select="@property"/>.ToString( 'd')
#end
</xsl:when>
<xsl:when test="ancestor::adl:entity/adl:property[@name=$prop]/@type='entity'">
#if( $instance.<xsl:value-of select="$prop"/>)
$instance.<xsl:value-of select="$prop"/>.UserIdentifier
#end
</xsl:when>
<xsl:otherwise>
$!instance.<xsl:value-of select="@property"/>
$!instance.<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
</xsl:attribute>
Edit!
</a>
</td>
<xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into
the HREF below -->
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="sep">
<xsl:choose>
<xsl:when test="position()=1">?</xsl:when>
<xsl:otherwise>&amp;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="ancestor::adl:entity/adl:form">
<!-- by default create a link to each form declared for the entity.
We probably need a means of overriding this -->
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( @name, '.rails', $keys)"/>
</xsl:attribute>
<xsl:value-of select="@name"/>!
</a>
</td>
</xsl:for-each>
</tr>
#end
</xsl:when>
#end <!-- of iteration foreach( $instance in $instances) -->
</xsl:when> <!-- close of @properties='listed ' -->
<xsl:otherwise>
<!-- properties are not 'listed' -->
<tr>
<xsl:for-each select="ancestor::entity/property[@distinct='user']">
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
<th>
<xsl:choose>
<xsl:when test="prompt[@locale=$locale]">
<xsl:value-of select="prompt[@locale=$locale]/@prompt"/>
<xsl:when test="adl:prompt[@locale=$locale]">
<xsl:value-of select="adl:prompt[@locale=$locale]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@name"/>
@ -1115,7 +1180,9 @@
</xsl:choose>
</th>
</xsl:for-each>
<th>-</th>
<xsl:for-each select="ancestor::adl:entity/adl:form">
<th>-</th>
</xsl:for-each>
</tr>
#foreach( $instance in $instances)
#if ( $velocityCount % 2 == 0)
@ -1124,22 +1191,48 @@
#set( $oddity = "odd")
#end
<tr class="$oddity">
<xsl:for-each select="ancestor::entity/property[@distinct='user']">
<xsl:for-each select="ancestor::adl:entity/adl:property[@distinct='user']">
<td>
$!instance.<xsl:value-of select="@name"/>
<xsl:choose>
<xsl:when test="@type='entity'">
#if( $instance.<xsl:value-of select="@name"/>)
$instance.<xsl:value-of select="@name"/>.UserIdentifier
#end
</xsl:when>
<xsl:otherwise>
$!instance.<xsl:value-of select="@name"/>
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( $action, '.rails?', ../@name, 'Id=$instance.', ../@name, 'Id')"/>
</xsl:attribute>
Edit!
</a>
</td>
</tr>
#end
</xsl:otherwise>
<xsl:variable name="keys">
<!-- assemble keys in a Velocity-friendly format, then splice it into
the HREF below -->
<xsl:for-each select="ancestor::adl:entity/adl:key/adl:property">
<xsl:variable name="sep">
<xsl:choose>
<xsl:when test="position()=1">?</xsl:when>
<xsl:otherwise>&amp;</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:value-of select="concat( $sep, @name, '=$instance.', @name)"/>
</xsl:for-each>
</xsl:variable>
<xsl:for-each select="ancestor::adl:entity/adl:form">
<!-- by default create a link to each form declared for the entity.
We probably need a means of overriding this -->
<td>
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat( @name, '.rails?', $keys)"/>
</xsl:attribute>
<xsl:value-of select="@name"/>!
</a>
</td>
</xsl:for-each>
</tr>
#end
</xsl:otherwise>
</xsl:choose>
</table>
</div>
@ -1152,33 +1245,33 @@
<xsl:template name="head">
<xsl:choose>
<xsl:when test="head">
<xsl:apply-templates select="head/*"/>
<xsl:when test="adl:head">
<xsl:apply-templates select="adl:head/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/application/content/head/*"/>
<xsl:apply-templates select="//adl:content/adl:head/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="top">
<xsl:choose>
<xsl:when test="top">
<xsl:apply-templates select="top/*"/>
<xsl:when test="adl:top">
<xsl:apply-templates select="adl:top/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/application/content/top/*"/>
<xsl:apply-templates select="//adl:content/adl:top/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="foot">
<xsl:choose>
<xsl:when test="foot">
<xsl:apply-templates select="foot/*"/>
<xsl:when test="adl:foot">
<xsl:apply-templates select="adl:foot/*"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="/application/content/foot/*"/>
<xsl:apply-templates select="//adl:content/adl:foot/*"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@ -1190,11 +1283,11 @@
<xsl:param name="fallback" select="Unknown"/>
<xsl:param name="node" select="."/>
<xsl:choose>
<xsl:when test="$node/prompt[@locale=$locale]">
<xsl:value-of select="$node/prompt[@locale=$locale][1]/@prompt"/>
<xsl:when test="$node/adl:prompt[@locale=$locale]">
<xsl:value-of select="$node/adl:prompt[@locale=$locale][1]/@prompt"/>
</xsl:when>
<xsl:when test="$node/prompt[@locale='default']">
<xsl:value-of select="$node/prompt[@locale='default'][1]/@prompt"/>
<xsl:when test="$node/adl:prompt[@locale='default']">
<xsl:value-of select="$node/adl:prompt[@locale='default'][1]/@prompt"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$fallback"/>