将参数传递给Visual Studio的XSLT调试器

Jus*_* R. 9 xslt debugging visual-studio-2010 xslt-tools

我正在使用Visual Studio调试转换.使用转换的应用程序通常也会传递一些参数:

XslTransform xslTransform = new XslTransform();
xslTransform.Load(myXslt);
XsltArgumentList transformArgumentList = new XsltArgumentList();
transformArgumentList.AddParam(paramName1, String.Empty, paramValue1); // this
transformArgumentList.AddParam(paramName2, String.Empty, paramValue2); // and this
xslTransform.Transform(inputStream, transformArgumentList, outputStream);
Run Code Online (Sandbox Code Playgroud)

如何在调试时设置参数?

Dim*_*hev 7

如何在调试时设置参数?

您应该使用以下XslCompiledTransform构造函数:

public XslCompiledTransform(
    bool enableDebug
)
Run Code Online (Sandbox Code Playgroud)

enableDebug参数设置为true.

然后,您可以开始调试,调试器将停止在XSLT转换中设置的断点.

这是一个例子:

// Enable XSLT debugging.
XslCompiledTransform xslt = new XslCompiledTransform(true);

// Load the style sheet.
xslt.Load("MyTransformation.xsl");

// Create the writer.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent=true;
XmlWriter writer = XmlWriter.Create("output.xml", settings);

// Execute the transformation.
xslt.Transform("books.xml", writer);
writer.Close();
Run Code Online (Sandbox Code Playgroud)

当然,如果你很懒,你可以只修改XSLT样式表中参数的值:

<xsl:param name="param1" select="SomeValue1"/>
<xsl:param name="param2" select="SomeValue2"/>
Run Code Online (Sandbox Code Playgroud)