Text Nodes do not appear in Trace API events
Added by Anonymous over 14 years ago
Legacy ID: #8133325 Legacy Poster: Gabor Guta (gguta)
I have written a class which implements the net.sf.saxon.trace.TraceListener interface. It works fine, but it doesn't emit any event in case of text nodes. Can anybody suggest some workaround? I need a tracein which I can see which instruction (or element) in the XSLT produces which part of the output. Thanks, Gabor
Replies (8)
Please register to reply
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8140701 Legacy Poster: Michael Kay (mhkay)
You appear to be correct; literal text output is not notified to the TraceListener. I'll look at adding this in a future release. I'm reluctant to do it in a maintenance patch because it could disrupt users who have working TraceListener code, for example the debuggers in Stylus Studio and Oxygen.
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8141667 Legacy Poster: Gabor Guta (gguta)
Approximately how long does it take? Can you provide a separated patch? Thank you for your quick answer! Gabor
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8142072 Legacy Poster: Michael Kay (mhkay)
I'll investigate this in more detail when I'm back in the office next week.
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8161599 Legacy Poster: Michael Kay (mhkay)
I've raised a bug and patch on this: 2970599 Literal text nodes in stylesheet not traced The text node will be traced as if it were wrapped in an xsl:text instruction. The actual InstructionInfo passed is the ValueOf instruction; where this is literal text, its getSelect() method returns a StringLiteral object containing the text to be output.
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8332036 Legacy Poster: Gabor Guta (gguta)
It seems that the info.getColumnNumber() and info.getLineNumber() return the start position of the dynamic context instead of the position of the element in the enter/leave(InstructionInfo info) callback. Is it possible to fix this or these information are already dropped at that point?
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8332413 Legacy Poster: Michael Kay (mhkay)
In my tests the line numbers appear to be correct. You'll have to be more precise about what you're doing.
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8332637 Legacy Poster: Gabor Guta (gguta)
Given the following trace listener: ----------------------------------------------------------------- public class TestListener extends XSLTTraceListener { ... public void enter(InstructionInfo info, XPathContext context) { int type = info.getConstructType(); System.err.println("Line: " + info.getLineNumber() + ", Column: " + info.getColumnNumber() + ", Type (const): " + instNames.get(type) + ", Type (id): " + type); } ... ----------------------------------------------------------------- and the following XSLT: ----------------------------------------------------------------- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="text" encoding="UTF-8"/> <xsl:template match="/"> <xsl:apply-templates select="database/table"/> </xsl:template> <xsl:preserve-space elements="*"/> <xsl:template match="table"> <xsl:variable name="itemname" select="@name"/> SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO drop procedure [dbo].[sp_<xsl:value-of select="$itemname"/>select_by_id] GO CREATE PROCEDURE sp<xsl:value-of select="$itemname"/> ... ----------------------------------------------------------------- It produce the following output: Line: 6, Column: 25, Type (const): XSL_TEMPLATE, Type (id): 181 Line: 7, Column: 48, Type (const): XSL_APPLY_TEMPLATES, Type (id): 130 Line: 7, Column: -1, Type (const): XPATH_IN_XSLT, Type (id): 2011 Line: 12, Column: 29, Type (const): XSL_TEMPLATE, Type (id): 181 Line: 14, Column: -1, Type (const): LET_EXPRESSION, Type (id): 2013 Line: 14, Column: -1, Type (const): XPATH_IN_XSLT, Type (id): 2011 Line: 12, Column: -1, Type (const): XSL_TEXT, Type (id): 182 Line: 22, Column: 60, Type (const): XSL_VALUE_OF, Type (id): 184 Line: 22, Column: -1, Type (const): XPATH_IN_XSLT, Type (id): 2011 Line: 12, Column: -1, Type (const): XSL_TEXT, Type (id): 182 Line: 25, Column: 55, Type (const): XSL_VALUE_OF, Type (id): 184 ... -------------------------------------------------------------------- Expected result in case of the first XSL_TEXT element: Line: 22, Column: 27, Type (const): XSL_TEXT, Type (id): 182 Expected result in case of the second XSL_TEXT element: Line: 25, Column: 22, Type (const): XSL_TEXT, Type (id): 182 Thank you for your help in advance!
RE: Text Nodes do not appear in Trace API events - Added by Anonymous over 14 years ago
Legacy ID: #8502140 Legacy Poster: Michael Kay (mhkay)
Sorry for dropping the ball on this one. I see what you mean. The code is designed to use the line number of the preceding sibling element for a text node, but actually it's using the line number of the parent element. I'll commit another patch to fix that. I'm not intending to start maintaining the line number of the text node itself.
Please register to reply