[英]Passing arguments to Visual Studio's XSLT debugger
I'm debugging a transform with Visual Studio. 我正在使用Visual Studio调试转换。 The application that uses the transform normally also passes in some parameters:
使用转换的应用程序通常也会传递一些参数:
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);
How can I set the parameters when debugging? 如何在调试时设置参数?
How can I set the parameters when debugging?
如何在调试时设置参数?
You should use the following XslCompiledTransform constructor : 您应该使用以下XslCompiledTransform构造函数 :
public XslCompiledTransform(
bool enableDebug
)
with the enableDebug
argument set to true
. 将
enableDebug
参数设置为true
。
Then you can start debugging and the debugger will stop on breakpoints set in your XSLT transformation . 然后,您可以开始调试,调试器将停止在XSLT转换中设置的断点 。
Here is an example: 这是一个例子:
// 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();
Of course, if you are lazy, you may just hardcode the values of the parameters in your XSLT stylesheet: 当然,如果你很懒,你可以只修改XSLT样式表中参数的值:
<xsl:param name="param1" select="SomeValue1"/>
<xsl:param name="param2" select="SomeValue2"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.