Hi,
I am trying to set the width variables <WIDTH>
and <WIDTH1>
within XSL which I am retriveing from the web.config within c# as below:
string Width1 = System.Configuration.ConfigurationSettings.AppSettings.Get("Width1");
string Width2 = System.Configuration.ConfigurationSettings.AppSettings.Get("Width2");
cslx.Xslt=@"<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:output method='html'/>
<xsl:template match='/'>
<link rel='stylesheet' type='text/css' href='/StyleSheets/test.css'/>
<xsl:apply-templates select='/Data/Test/TestItems/TestItem'/>
</xsl:template>
<xsl:template match='TestItem'>
<xsl:when='boolean($Link1Items)or boolean($Link2Items) or boolean($Link3Items)'>
<table width='<WIDTH1>' class='tablestyle '>
</xsl:when>
<xsl:otherwise>
<table width='<WIDTH2>' class='tablestyle '>
</xsl:otherwise>
</table>
</xsl:template>
</xsl:stylesheet>
";
// update subsitution parameters
cslx.Xslt = cslx.Xslt.Replace("<WIDTH1>", Width1);
cslx.Xslt = cslx.Xslt.Replace("<WIDTH2>", Width2);
But the HTML is not generated and an error is thrown regarding the table tag which is not closed.
I know the table tag must go inside each of the xsl:when and xsl:otherwise tags but I want to avoid this.
My problem is there is a lot XSL code between the tags and I want to avoid code duplication! Is there any other way I can acheive this?
Many Thanks,