简体   繁体   English

用于调试xslt的工具

[英]Tools for debugging xslt

I have a Java servlet which generates xml, translates it with an xslt stylesheet, and then displays the resulting HTML. 我有一个Java servlet,它生成xml,用xslt样式表进行翻译,然后显示生成的HTML。 This is the first time I've worked with xslt. 这是我第一次使用xslt。 What's a good way to debug xslt? 调试xslt的好方法是什么? I have (or can get) some sample XML files to apply the transform too. 我有(或可以得到)一些示例XML文件来应用转换。 But I'm not really even sure of the syntax so something that would give me syntax warnings would be great. 但我真的不确定语法,所以给我语法警告的东西会很棒。

If you want to do "printf-style" debugging and don't want to litter your output with debugging data, use the <xsl:message> tag to generate debugging output while processing the stylesheet. 如果要进行“printf-style”调试并且不希望使用调试数据<xsl:message>输出,请在处理样式表时使用<xsl:message>标记生成调试输出。 With the terminate="yes" attribute you can even halt the processing of the stylesheet. 使用terminate="yes"属性,您甚至可以暂停样式表的处理。

Xalan should give you useful errors when you try to use an invalid XSLT. 当您尝试使用无效的XSLT时,Xalan应该为您提供有用的错误。 If you want something more powerful, one option for debugging XSLT is Oxygen XML Editor . 如果你想要更强大的东西,调试XSLT的一个选项是Oxygen XML Editor It is integrated with Xalan and Saxon transform engines. 它与Xalan和Saxon变换引擎集成在一起。 Its debugging mode allows you to set breakpoints, watch variables, and provides other such basic debugging functionality. 它的调试模式允许您设置断点,监视变量,并提供其他此类基本调试功能。 It may be overkill for you want, but it's very good. 你想要它可能有点过分,但它非常好。

I once had to write and debug some complex XSLT documents. 我曾经不得不编写和调试一些复杂的XSLT文档。 At the time I used debugged "printf-style" by outputting a lot of intermediate values. 当时我通过输出大量中间值来使用调试的“printf-style”。 I later found out that there is a much easier way to do this - Altova XMLSpy . 我后来发现有一种更简单的方法 - Altova XMLSpy It allows you to single-step through the style-application process, watch intermediate output, etc. etc. 它允许您单步执行样式应用程序,观察中间输出等。

VS8 also has XSLT debugging support. VS8还具有XSLT调试支持。 See here: http://msdn.microsoft.com/en-us/library/ms255605(VS.80).aspx 请看: http//msdn.microsoft.com/en-us/library/ms255605(VS.80).aspx

I should also mention that both XMLSpy and VS8 have syntax highlighting as well. 我还要提到XMLSpy和VS8都有语法高亮。 If you specify a XSD in your XML, VS8 even gives you intellisense! 如果在XML中指定XSD,VS8甚至可以为您提供智能感知!

I work with XSLT nearly every day, and have for six or seven years. 我几乎每天都在使用XSLT,并且有六到七年的时间。

I've found that "printf-style" debugging of XSLT is so effective that I've never derived a benefit from using any other debugging mechanism (and I've tried XMLSpy and Visual Studio). 我发现XSLT的“printf-style”调试非常有效,我从来没有从使用任何其他调试机制中获益(我已经尝试过XMLSpy和Visual Studio)。 It does sometimes happen that I want to be able to inspect the value of a variable and building logic that outputs it is a hassle. 有时会发生这种情况,我希望能够检查变量的值并构建输出它的逻辑是一件麻烦事。 But that's pretty rare. 但这非常罕见。

It may be that having a debugger would have made learning XSLT easier. 可能有一个调试器会使学习 XSLT更容易。 (Anything would have.) (一切都会。)

when learning, a syntax highlighting editor is usually enough for me (of course with the ref doc open on another window. 学习时,语法高亮编辑器通常对我来说足够了(当然,在另一个窗口打开了ref doc。

Kate is a great editor for XML and XSLT. Kate是XML和XSLT的优秀编辑器。

Xselerator is s great XSL debugging tool that will: Xselerator是一个很棒的XSL调试工具,它将:

  • Let you step through your XSLT dom 让你逐步完成你的XSLT dom
  • Create watch statements 创建观察声明
  • Evaluate XPath statements against you XML DOM 针对您的XML DOM评估XPath语句
  • IDE with Intellisense 具有Intellisense的IDE

I've used this for years and it is a great tool. 我已经使用了多年,它是一个很棒的工具。

PHPStorm and the other IntelliJ IDEs (commercial) support debugging XSLT . PHPStorm和其他IntelliJ IDE(商业)支持调试XSLT You can step through the document and see the output being generated step by step. 您可以单步执行文档,并逐步查看生成的输出。

Microsoft Visual Studio is also a great tool for xslt debugger. Microsoft Visual Studio也是xslt调试器的一个很好的工具。 But you must install the 但你必须安装

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM