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

时间:2010-10-09 19:58:13

标签: debugging visual-studio-2010 xslt-tools xslt

我正在使用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);

调试时如何设置参数?

1 个答案:

答案 0 :(得分:7)

  

如何设置参数   调试?

您应该使用以下XslCompiledTransform constructor

public XslCompiledTransform(
    bool enableDebug
)

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();

当然,如果你很懒,你可能只需在XSLT样式表中硬编码参数的值:

<xsl:param name="param1" select="SomeValue1"/>
<xsl:param name="param2" select="SomeValue2"/>
相关问题