So I’m transforming an XML feed into HTML and in doing so give the end-user the ability to choose 1 of 3 color schemes. Depending on the color scheme chosen I am trying to assign values to parameters in a call-template command that will render the XML.
I am fairly new to XSL so feel free to point me in a better methodology
Here is an example of my code:
<xsl:template match="/">
<xsl:variable name="basic_head_title_color">#414141</xsl:variable>
<xsl:variable name="basic_head_title_size">18px</xsl:variable>
<xsl:variable name="basic_head_desc_color">#8b8b8b</xsl:variable>
<xsl:variable name="contrast_head_title_color">#ffffff</xsl:variable>
<xsl:variable name="contrast_head_title_size">18px</xsl:variable>
<xsl:variable name="contrast_head_desc_color">#e1e1e1</xsl:variable>
<xsl:variable name="black_head_title_color">#ffffff</xsl:variable>
<xsl:variable name="black_head_title_size">18px</xsl:variable>
<xsl:variable name="black_head_desc_color">#e1e1e1</xsl:variable>
<xsl:when test="$display_theme = 'basic'" >
<xsl:variable name ="chosen_head_title_color" select="basic_head_title_color"/>
<xsl:variable name ="chosen_head_title_size" select="basic_head_title_size"/>
<xsl:variable name ="chosen_head_desc_color" select="basic_head_desc_color"/>
</xsl:when>
<xsl:when test="$display_theme = 'contrast'" >
<xsl:variable name ="chosen_head_title_color" select="contrast_head_title_color"/>
<xsl:variable name ="chosen_head_title_size" select="contrast_head_title_size"/>
<xsl:variable name ="chosen_head_desc_color" select="contrast_head_desc_color"/>
</xsl:when>
<xsl:when test="$display_theme = 'black'" >
<xsl:variable name ="chosen_head_title_color" select="black_head_title_color"/>
<xsl:variable name ="chosen_head_title_size" select="black_head_title_size"/>
<xsl:variable name ="chosen_head_desc_color" select="black_head_desc_color"/>
</xsl:when>
<xsl:call-template name="render_xml">
<xsl:with-param name="head_title_color" select="chosen_head_title_color" />
<xsl:with-param name="head_title_size" select="chosen_head_title_size" />
<xsl:with-param name="head_desc_color" select="chosen_head_desc_color" />
</xsl:call-template>
</template>
Your XSLT is invalid in a few places, but how’s this?