>You can set the ProblemListener for the XalanTransformer instance, and most >errors (but not all, unfortunately) will come through the call. See the >classes ProblemListenerDefault and XalanTransformerProblemListener for more >information. The purpose of the latter is to allow re-direction of >warnings to a stream specified by the user.
I've looked at these classes, but how do I use them? Can I use these classes as is, or do I need to derive my own class from ProblemListener to cache the line and column number information? From the behavior of XalanTransformer::transform(), which is to write the error message to cerr (I think), I assumed that a DefaultProblemListener exists and is part of my XalanTransformer object. But if that is so, why do I get a null return from getProblemListener? >However, since errors which have line number information should have that >information in the string returned by getLastError(), this may be a bug. >Can you describe what sort of error it is? Hmm, I don't think I ever see line number information from getLastError, for any error. At any rate, it's easy to create the problem. Here's a simple stylesheet: <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:template match="@*|node()"> <xsl:apply-templates select="@*|node()"> </xsl:template> </xsl:stylesheet> Note that the apply-templates node is missing a trailing slash. I ran xalan.exe under the windows debugger, and set a breakpoint after the call to transform and before the call to getLastError. I specified any old xml file as source, and this stylesheet as the script. At the breakpoint, the output window shows this message: XSLT warning: Fatal Error at (file test1.xsl, line 5, column 16): Expected end o f tag 'xsl:apply-templates' (test1.xsl, line 5, column 16) (Note: the column number is incorrect because I changed some tabs to spaces for the purposes of this email message.) Then I step past the getLastError statement, and this message gets output. Expected end of tag 'xsl:apply-templates' So getLastError() only returns the the message, without the filename, line number, or column number. The first message is output someplace inside the transform() call, I haven't tracked that down. Not a highly sophisticated debugging scheme, I realize, but it's a way for you to easily duplicate the problem. :) Oh, I should mention I'm running the standard 1.4 release, not the interim 2002-10-21 release. Don
