BAM Template Developer Guide / Tcl basics and samples |
The code for your application can be generated using XSLT instead of Tcl.
This example demonstrates how to generate a file with AG using XSL Translator.
Instead of generating 4gl as the template does, we'll generate a per file (Genero form definition file). This example uses a 4rd (report data) file and generate a per form file with formfields corresponding to the 4rd record. We'll add an additional property frmLabel on each record field, which will be displayed to the left of each per file formfield.
<File extension="4rd"> <DynamicProperties> <DynamicProperty name="foreignFields" type="FIELDS" label="foreignFields" initialValue="" dynamicContent="srcFieldsContent" editorInfo="isDynamic:true" /> <DynamicProperty name="primaryFields" type="FIELDS" label="primaryFields" initialValue="" dynamicContent="dstFieldsContent" editorInfo="isDynamic:true" /> <DynamicProperty name="frmlabel" type="TEXT" label="Label FRM" initialValue="" /> </DynamicProperties> <Items> <Item nodeName="Relation" srcProperty="foreignFields" dstProperty="primaryFields" dynamicProperties="primaryFields;foreignFields"/> <Item nodeName="RecordField" dynamicProperties="frmlabel" /> </Items> </File>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" /> <xsl:template match="/"> --This is generated by the XSL DATABASE <xsl:for-each select="//Module"><xsl:value-of select="@databaseName"/> </xsl:for-each> LAYOUT GRID { <xsl:for-each select="//Fields/Field"> <xsl:value-of select="DynamicProperties/DynamicProperty[@name='frmlabel'] /@value"/>: [<xsl:value-of select="@column"/>] </xsl:for-each> } END -- LAYOUT TABLES <xsl:for-each select="//Record"><xsl:value-of select="@table"/> </xsl:for-each> ATTRIBUTES <xsl:for-each select="//Fields/Field"> <xsl:value-of select="@column"/> = <xsl:value-of select="@table"/>. <xsl:value-of select="@column"/>; </xsl:for-each> END -- ATTRIBUTES </xsl:template> </xsl:stylesheet>
<BuildRule additionalDependencies="" commands="$(generate) -depth 0 -ba "$(BAFilePath)" "$(InputPath)";fglxslp -o $(InputDir)/$(InputBaseName)per $(TemplateDir)/managedTextForm.xsl $(InputDir)/$(InputBaseName).xml;" description="4RD Report Data compiler" enabled="true" fileType="application/generostudio-4rd" id="1319189142826" intermediateFiles="" outputFiles="$(InputDir)/$(InputBaseName)per "/>
The same Build Rule displayed in a Genero Studio dialog:
Figure 1. Build Rule
Figure 2. per form