Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload