This is either the same problem as
 
http://sourceforge.net/tracker/index.php?func=detail&aid=1094080&group_id=29872&atid=397617
 
or something very closely related - your code doesn't quite match the conditions described in the bug description, but the symptoms are identical. It works on my current build, but I can't tell if the patch on the site is sufficient to cure it.
 
(Since 8.1, Saxon tracing works by inserting code into the abstract syntax tree produced at compile time, rather than by means of run-time tests. This modification of the tree is a fairly delicate process, so there have been one or two bugs with it. It also tends to mean that the execution plan you see while tracing is not necessarily the same as the execution plan that used when tracing is off. The particular error reported here is an inconsistency in the annotated syntax tree.)
 
Michael Kay
http://www.saxonica.com/


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Marc Pellmann
Sent: 21 January 2005 13:04
To: saxon-help@lists.sourceforge.net
Subject: Re: [saxon] another TraceListener Problem

Hi Mike!
No, sorry, this information is not sent to the trace listener. The select expression on the xsl:value-of instruction should be available, but not its result. 
Is there a possibility to get this in a newer version?

And now an other problem:

I have a script, that works well if have not added a TraceListener, but throws an exception if I have added one (My listener, but there is the same exception with the XSLTTraceListener e.g.).

I have added the trace, the script and the source

--- trace ---

java.lang.AssertionError: Incestuous relationship!
    at net.sf.saxon.expr.ComputedExpression.setParentExpression(ComputedExpression.java:67)
    at net.sf.saxon.style.XSLChoose.compile(XSLChoose.java:136)
    at net.sf.saxon.style.StyleElement.compileSequenceConstructor(StyleElement.java:1368)
    at net.sf.saxon.style.XSLTemplate.compile(XSLTemplate.java:244)
    at net.sf.saxon.style.XSLStylesheet.compileStylesheet(XSLStylesheet.java:938)
    at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:290)
    at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:112)
    at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:124)
    at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:79)
...

--- script ---

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="xml" encoding="ISO-8859-1"/>
  <xsl:template match="CsvRootTag">
    <AmsStammdaten>
      <xsl:for-each select="Csv[A1='{']">
        <!--following-sibling::Csv[generate-id(preceding-sibling::Csv[A1='{'][1]) =  generate-id(current())]-->
        <xsl:variable name="artikel" select="following-sibling::Csv[generate-id(preceding-sibling::Csv[A1='{'][1]) =  generate-id(current())]"/>
        <xsl:if test="starts-with($artikel[1]/A1, 'c 1 ')=false()">
          <Artikel>
            <xsl:apply-templates select="$artikel" mode="call"/>
          </Artikel>
        </xsl:if>
      </xsl:for-each>
      <xsl:value-of select="system-property('xsl:vendor')"/>
    </AmsStammdaten>
  </xsl:template>
  <xsl:template match="Csv" mode="call">
    <xsl:choose>
      <xsl:when test="starts-with(A1, 'c')">
        <xsl:element name="DistributorProductId">
          <xsl:value-of select="substring-before(substring-after(A1, ' '), ' ')"/>
        </xsl:element>
        <xsl:element name="action">
          <xsl:value-of select="substring(substring-after(substring-after(A1, ' '), ' '), 1, 6)"/>
        </xsl:element>
      </xsl:when>
      <xsl:when test="A1='f 42'">
        <xsl:element name="EAN">
          <xsl:value-of select="A2"/>
        </xsl:element>
      </xsl:when>
      <xsl:when test="A1='f 46'">
        <xsl:element name="Titel">
          <xsl:value-of select="A2"/>
        </xsl:element>
      </xsl:when>
      <xsl:when test="A1='f 48'">
        <xsl:element name="VerkaufsPreis">
          <xsl:value-of select="A2"/>
        </xsl:element>
      </xsl:when>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

--- source ---

<?xml version="1.0" encoding="ISO-8859-1"?>

<CsvRootTag>
  <Csv>
    <A1>{</A1>
  </Csv>
  <Csv>
    <A1>c 206558 FTCNDX;</A1>
  </Csv>
  <Csv>
    <A1>f 41</A1>
    <A2>4015222553940</A2>
    <A3>;</A3>
  </Csv>
  <Csv>
    <A1>f 89</A1>
    <A2>BURELL,KENNY*MIDNIGHT BLUE</A2>
    <A3>;</A3>
  </Csv>
  <Csv>
    <A1>f 44</A1>
    <A2>Burrell,Kenny</A2>
    <A3>;</A3>
  </Csv>
  <Csv>
    <A1>f 46</A1>
    <A2>Midnight Blue Crudy van Gelder</A2>
    <A3>;</A3>
  </Csv>
  <Csv>
    <A1>f 45</A1>
    <A2/>
    <A3>;</A3>
  </Csv>
  <Csv>
    <A1>f 53</A1>
    <A2>Burrell,Kenny</A2>
    <A3>;</A3>
  </Csv>
</CsvRootTag>

-- 
Viele Grüße / best regards

Marc Pellmann
_______________________________
inubit - the integration experts
inubit AG
Lützowstraße 105-106
D-10785 Berlin
Fon: +49.30. 72 61 12-132
Fax: +49.30. 72 61 12-100
Freecall: 0800-go inubit
Web: www.inubit.com