Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ol> <li>Use <a href="http://msdn.microsoft.com/en-us/library/dfktf882.aspx" rel="nofollow noreferrer">XSLT parameters</a> to pass parameters to your stylesheet, not string replacement. </li> <li>Your XSLT is not a well formed XML document. To manipulate attributes, you have to use your <code>xsl:when</code>s inside an <code>xsl:attribute</code> element. In your case your code should be like this:</li> </ol> <hr> <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:param name='width1' /&gt; &lt;xsl:param name='width2' /&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;table class='tablestyle'&gt; &lt;xsl:attribute name='width'&gt; &lt;xsl:choose&gt; &lt;xsl:when test='boolean($Link1Items)or boolean($Link2Items) or boolean($Link3Items)'&gt;&lt;xsl:value-of select='$width1' /&gt;&lt;/xsl:when&gt; &lt;xsl:otherwise&gt;&lt;xsl:value-of select='$width2' /&gt;&lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:attribute&gt; &lt;/table&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; "; var xslt = new XslCompiledTransform(); xslt.Load(new XmlTextReader(new StringReader(cslx.Xslt))); var args = new XsltArgumentList(); args.AddParam("width1", "", Width1); args.AddParam("width2", "", Width2); // whenever you want to transform var writer = new XmlWriter("output.xml"); xslt.Transform(document, args, writer); </code></pre>
 

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