Project

Profile

Help

xsl:sequence trace listener calls

Added by Anonymous about 18 years ago

Legacy ID: #3592284 Legacy Poster: sudhan (umasudhan)

Hi I am using a cutom xslt trace listener in which i overrode method enter(InstructionInfo,XPathContext) of AbstractTraceListener. I am getting a callback for all instructions except for xsl:sequence. Could somebody please tell me why? I am using saxon version 8.3 Thanks


Replies (6)

Please register to reply

RE: xsl:sequence trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3592505 Legacy Poster: Michael Kay (mhkay)

I can't investigate as far back as 8.3. In the current code the situation is that the xsl:sequence instruction itself is not notified to the tracelistener: this is because there is no run-time code associated with xsl:sequence, it is simply a compile-time wrapper around an XPath expression. The evaluation of the "select" expression however is notified to the tracelistener, but as an expression rather than an instruction. The standard trace listener ignores expression-level calls, and it's quite possible if your own trace listener is modelled on the standard one that it does so too. Michael Kay

xsl trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3601151 Legacy Poster: sudhan (umasudhan)

Hi Michael, Thanks for the reply. I have another doubt related to trace listeners. Like in the previous post, I have a custom XSLTTraceListener in which i have overriden method: enter(InstructionInfo info, XPathContext context). In this method I do the following: int constructType = info.getConstructType(); if (constructType == StandardNames.XSL_COPY_OF) { XSLCopyOf copyOf = (XSLCopyOf) info; copyOf.prepareAttributes(); Expression expression = copyOf.compile(null); Item item = expression.evaluateItem(context); ... } It throws an exception with the following stack trace: (Please see end for xslt fragment executed) IllegalStateException:Variable $aaa has not been fixed up at net.sf.saxon.expr.VariableReference.evaluateVariable(VariableReference.java:218) at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:194) at net.sf.saxon.expr.PathExpression.iterate(PathExpression.java:662) at net.sf.saxon.expr.GeneralComparison.effectiveBooleanValue(GeneralComparison.java:279) at net.sf.saxon.expr.FilterIterator$NonNumeric.matches(FilterIterator.java:145) at net.sf.saxon.expr.FilterIterator.getNextMatchingItem(FilterIterator.java:62) at net.sf.saxon.expr.FilterIterator.next(FilterIterator.java:44) at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:79) at net.sf.saxon.expr.MappingIterator.next(MappingIterator.java:61) at net.sf.saxon.instruct.Instruction.evaluateItem(Instruction.java:309) at net.sf.saxon.instruct.CopyOf.evaluateItem(CopyOf.java:308) XSLT fragment: <xsl:template match="/"> <xsl:variable name="aaa">String</xsl:variable> <xsl:copy-of select="//*[local-name() != $aaa/text()]"/> ... Could you please tell me what I am doing wrong? Basically I want to know the number of element nodes in the output got when the xpath expression following copy is evaluated Thanks Sudhan

RE: xsl:sequence trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3601190 Legacy Poster: Michael Kay (mhkay)

The TraceListener interface is not very well-protected (which is deliberate because it gives debuggers access to all sorts of internal data structures). Unfortunately this means that if you use methods without fully understanding them, you can get yourself into all sorts of difficulties. What you have done here is to call methods (prepareAttributes and compile) that were used at compile time and should never be called again at run-time. You can get the XPath expression in the select attribute of the xsl:copy-of instruction safely enough (as a string) using a method such as getAttributeList() or getAttributeValue() on the XSLCopyOf object. I can't immediately think of any way of getting the compiled expression, but I'm not sure whether this is what you want to do anyway. In fact, I'm not really clear what you are trying to achieve. As a general point, I would say that if you want to get into Saxon's more intimate interfaces you are probably going to have to spend some time studying the source code and getting to understand it.

RE: xsl:sequence trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3601210 Legacy Poster: sudhan (umasudhan)

Basically what i am trying to do is to determine the number of element nodes which will be output as a result of the copy-of statement. Is there any way in which I can evaluate the xpath expression and figure out the number and structure of element nodes in the output? I use this info to build a model which I then use for backmapping- on clicking a particular element node in the output, I highlight the relevant xslt instruction node. Thanks Sudhan

RE: xsl:sequence trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3601266 Legacy Poster: Michael Kay (mhkay)

It can be done - I know, because there are tools like Stylus Studio and Oxygen that do it. But I'm afraid that advice in this area goes beyond what I can offer by way of free support. Michael Kay

RE: xsl:sequence trace listener calls - Added by Anonymous about 18 years ago

Legacy ID: #3601276 Legacy Poster: sudhan (umasudhan)

Thanks anyway :)

    (1-6/6)

    Please register to reply