1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/XSLForms/XSL/PrepareMacro.xsl Fri Sep 30 22:53:43 2005 +0000
1.3 @@ -0,0 +1,62 @@
1.4 +<?xml version="1.0"?>
1.5 +<xsl:stylesheet version="1.0"
1.6 + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
1.7 + xmlns:template="http://www.boddie.org.uk/ns/xmltools/template">
1.8 +
1.9 + <xsl:output indent="yes"/>
1.10 +
1.11 + <xsl:template match="*[@template:attribute-field]">
1.12 + <xsl:copy>
1.13 + <xsl:apply-templates select="@*[local-name() != 'attribute-field']"/>
1.14 + <xsl:attribute name="template:attribute"><xsl:value-of select="@template:attribute-field"/></xsl:attribute>
1.15 + <xsl:attribute name="name">{template:this-attribute()}</xsl:attribute>
1.16 + <xsl:attribute name="value">{$this-value}</xsl:attribute>
1.17 + <xsl:apply-templates select="*|node()"/>
1.18 + </xsl:copy>
1.19 + </xsl:template>
1.20 +
1.21 + <xsl:template match="*[@template:selector-field]">
1.22 + <xsl:variable name="field-name" select="@template:selector-field"/>
1.23 + <xsl:copy>
1.24 + <xsl:apply-templates select="@*[local-name() != 'selector-field']"/>
1.25 + <xsl:attribute name="name"><xsl:value-of select="$field-name"/>={template:this-element()}</xsl:attribute>
1.26 + <xsl:apply-templates select="*|node()"/>
1.27 + </xsl:copy>
1.28 + </xsl:template>
1.29 +
1.30 + <xsl:template match="*[@template:multiple-choice-field]">
1.31 + <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-field, ',')"/>
1.32 + <xsl:variable name="field-attr" select="substring-after(@template:multiple-choice-field, ',')"/>
1.33 + <xsl:copy>
1.34 + <xsl:apply-templates select="@*[local-name() != 'multiple-choice-field']"/>
1.35 + <xsl:attribute name="template:element"><xsl:value-of select="$field-element"/></xsl:attribute>
1.36 + <xsl:attribute name="name">{template:new-attribute('<xsl:value-of select="$field-attr"/>')}</xsl:attribute>
1.37 + <xsl:apply-templates select="*|node()"/>
1.38 + </xsl:copy>
1.39 + </xsl:template>
1.40 +
1.41 + <xsl:template match="*[@template:multiple-choice-value]">
1.42 + <xsl:variable name="field-element" select="substring-before(@template:multiple-choice-value, ',')"/>
1.43 + <xsl:variable name="field-attr-info" select="substring-after(@template:multiple-choice-value, ',')"/>
1.44 + <xsl:variable name="field-attr" select="substring-before($field-attr-info, ',')"/>
1.45 + <xsl:variable name="field-set-attr" select="substring-after($field-attr-info, ',')"/>
1.46 + <xsl:copy>
1.47 + <xsl:apply-templates select="@*[local-name() != 'multiple-choice-value']"/>
1.48 + <xsl:attribute name="template:element"><xsl:value-of select="$field-element"/></xsl:attribute>
1.49 + <xsl:attribute name="template:expr">@<xsl:value-of select="$field-attr"/> = ../@<xsl:value-of select="$field-attr"/></xsl:attribute>
1.50 + <xsl:attribute name="template:expr-attr"><xsl:value-of select="$field-set-attr"/></xsl:attribute>
1.51 + <xsl:attribute name="template:value">@<xsl:value-of select="$field-attr"/></xsl:attribute>
1.52 + <xsl:attribute name="value">{@<xsl:value-of select="$field-attr"/>}</xsl:attribute>
1.53 + <xsl:apply-templates select="*|node()"/>
1.54 + </xsl:copy>
1.55 + </xsl:template>
1.56 +
1.57 + <!-- Replicate unknown elements. -->
1.58 +
1.59 + <xsl:template match="@*|node()">
1.60 + <xsl:copy>
1.61 + <xsl:apply-templates select="@*|node()"/>
1.62 + </xsl:copy>
1.63 + </xsl:template>
1.64 +
1.65 +</xsl:stylesheet>