1.1 --- a/XSLForms/XSL/PrepareMacro.xsl Mon Oct 03 00:49:15 2005 +0000
1.2 +++ b/XSLForms/XSL/PrepareMacro.xsl Mon Oct 03 00:52:17 2005 +0000
1.3 @@ -5,6 +5,8 @@
1.4
1.5 <xsl:output indent="yes"/>
1.6
1.7 + <!-- Input fields. -->
1.8 +
1.9 <xsl:template match="*[@template:attribute-field]">
1.10 <xsl:copy>
1.11 <!-- Remove attribute-field and replace name and value. -->
1.12 @@ -16,6 +18,20 @@
1.13 </xsl:copy>
1.14 </xsl:template>
1.15
1.16 + <!-- Text areas and other elements without value attributes. -->
1.17 +
1.18 + <xsl:template match="*[@template:attribute-area]">
1.19 + <xsl:copy>
1.20 + <!-- Remove attribute-field and replace name and value. -->
1.21 + <xsl:apply-templates select="@*[local-name() != 'attribute-area' and local-name() != 'name' and local-name() != 'value']"/>
1.22 + <xsl:attribute name="template:attribute"><xsl:value-of select="@template:attribute-area"/></xsl:attribute>
1.23 + <xsl:attribute name="name">{template:this-attribute()}</xsl:attribute>
1.24 + <xsl:apply-templates select="*|node()"/>
1.25 + </xsl:copy>
1.26 + </xsl:template>
1.27 +
1.28 + <!-- Buttons whose state varies according to an attribute. -->
1.29 +
1.30 <xsl:template match="*[@template:attribute-button]">
1.31 <xsl:variable name="field-attr" select="substring-before(@template:attribute-button, ',')"/>
1.32 <xsl:variable name="field-set-attr" select="substring-after(@template:attribute-button, ',')"/>
1.33 @@ -30,16 +46,28 @@
1.34 </xsl:copy>
1.35 </xsl:template>
1.36
1.37 + <!-- Selectors. -->
1.38 +
1.39 <xsl:template match="*[@template:selector-field]">
1.40 - <xsl:variable name="field-name" select="@template:selector-field"/>
1.41 + <xsl:variable name="field-name" select="substring-before(@template:selector-field, ',')"/>
1.42 + <xsl:variable name="affected-element" select="substring-after(@template:selector-field, ',')"/>
1.43 <xsl:copy>
1.44 <!-- Remove selector-field and replace name. -->
1.45 <xsl:apply-templates select="@*[local-name() != 'selector-field' and local-name() != 'name']"/>
1.46 - <xsl:attribute name="name"><xsl:value-of select="$field-name"/>={template:this-element()}</xsl:attribute>
1.47 + <xsl:choose>
1.48 + <xsl:when test="$field-name != ''">
1.49 + <xsl:attribute name="name"><xsl:value-of select="$field-name"/>={template:this-element()}</xsl:attribute>
1.50 + </xsl:when>
1.51 + <xsl:otherwise>
1.52 + <xsl:attribute name="name"><xsl:value-of select="@template:selector-field"/>={template:this-element()}</xsl:attribute>
1.53 + </xsl:otherwise>
1.54 + </xsl:choose>
1.55 <xsl:apply-templates select="*|node()"/>
1.56 </xsl:copy>
1.57 </xsl:template>
1.58
1.59 + <!-- Multiple choice fields, represented by menus and listboxes. -->
1.60 +
1.61 <xsl:template match="*[@template:multiple-choice-field]">
1.62 <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-field, ',')"/>
1.63 <xsl:variable name="field-attr" select="substring-after(@template:multiple-choice-field, ',')"/>
1.64 @@ -52,6 +80,25 @@
1.65 </xsl:copy>
1.66 </xsl:template>
1.67
1.68 + <!-- Multiple choice list fields, represented by menus and listboxes with multiple values. -->
1.69 +
1.70 + <xsl:template match="*[@template:multiple-choice-list-field]">
1.71 + <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-list-field, ',')"/>
1.72 + <xsl:variable name="field-list-info" select="substring-after(@template:multiple-choice-list-field, ',')"/>
1.73 + <xsl:variable name="field-list-element" select="substring-before($field-list-info, ',')"/>
1.74 + <xsl:variable name="field-list-attr" select="substring-after($field-list-info, ',')"/>
1.75 + <xsl:copy>
1.76 + <!-- Remove multiple-choice-list-field and replace name. -->
1.77 + <xsl:apply-templates select="@*[local-name() != 'multiple-choice-list-field' and local-name() != 'name']"/>
1.78 + <xsl:attribute name="template:element"><xsl:value-of select="$field-element"/></xsl:attribute>
1.79 + <xsl:attribute name="name">{template:list-attribute('<xsl:value-of select="$field-list-element"/>',
1.80 + '<xsl:value-of select="$field-list-attr"/>')}</xsl:attribute>
1.81 + <xsl:apply-templates select="*|node()"/>
1.82 + </xsl:copy>
1.83 + </xsl:template>
1.84 +
1.85 + <!-- Multiple choice values, represented by option elements. -->
1.86 +
1.87 <xsl:template match="*[@template:multiple-choice-value]">
1.88 <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-value, ',')"/>
1.89 <xsl:variable name="field-attr-info" select="substring-after(@template:multiple-choice-value, ',')"/>
1.90 @@ -69,6 +116,25 @@
1.91 </xsl:copy>
1.92 </xsl:template>
1.93
1.94 + <!-- Multiple choice list values, represented by option elements. -->
1.95 +
1.96 + <xsl:template match="*[@template:multiple-choice-list-value]">
1.97 + <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-list-value, ',')"/>
1.98 + <xsl:variable name="field-attr-info" select="substring-after(@template:multiple-choice-list-value, ',')"/>
1.99 + <xsl:variable name="field-attr" select="substring-before($field-attr-info, ',')"/>
1.100 + <xsl:variable name="field-set-attr" select="substring-after($field-attr-info, ',')"/>
1.101 + <xsl:copy>
1.102 + <!-- Remove multiple-choice-value and replace value. -->
1.103 + <xsl:apply-templates select="@*[local-name() != 'multiple-choice-list-value' and local-name() != 'value']"/>
1.104 + <xsl:attribute name="template:element"><xsl:value-of select="$field-element"/></xsl:attribute>
1.105 + <xsl:attribute name="template:expr">@value-is-set</xsl:attribute>
1.106 + <xsl:attribute name="template:expr-attr"><xsl:value-of select="$field-set-attr"/></xsl:attribute>
1.107 + <xsl:attribute name="template:value">@<xsl:value-of select="$field-attr"/></xsl:attribute>
1.108 + <xsl:attribute name="value">{@<xsl:value-of select="$field-attr"/>}</xsl:attribute>
1.109 + <xsl:apply-templates select="*|node()"/>
1.110 + </xsl:copy>
1.111 + </xsl:template>
1.112 +
1.113 <!-- Replicate unknown elements. -->
1.114
1.115 <xsl:template match="@*|node()">