I have a Java servlet which generates xml, translates it with an xslt stylesheet, and then displays the resulting HTML. This is the first time I've worked with xslt. What's a good way to debug xslt? I have (or can get) some sample XML files to apply the transform too. But I'm not really even sure of the syntax so something that would give me syntax warnings would be great.
when learning, a syntax highlighting editor is usually enough for me (of course with the ref doc open on another window.
Kate is a great editor for XML and XSLT.
I once had to write and debug some complex XSLT documents. At the time I used debugged "printf-style" by outputting a lot of intermediate values. I later found out that there is a much easier way to do this - Altova XMLSpy. It allows you to single-step through the style-application process, watch intermediate output, etc. etc.
VS8 also has XSLT debugging support. See here: 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. If you specify a XSD in your XML, VS8 even gives you intellisense!
As I've been searching for an answer, I've come across a tool called Xalan. Has anyone had any experience with it? It appears at first blush to do what I want.
Xalan should give you useful errors when you try to use an invalid XSLT. If you want something more powerful, one option for debugging XSLT is Oxygen XML Editor. It is integrated with Xalan and Saxon transform engines. 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 work with XSLT nearly every day, and have for six or seven years.
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). 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. (Anything would have.)
Xselerator is s great XSL debugging tool that will:
- Let you step through your XSLT dom
- Create watch statements
- Evaluate XPath statements against you XML DOM
- IDE with Intellisense
I've used this for years and it is a great tool.
I use Cooktop which is pretty good, nice and simple :
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. With the terminate="yes"
attribute you can even halt the processing of the stylesheet.