At the time the trace listener is notified of the entry to a for-each, the context node is the node used as the context node for evaluating the select expression on the for-each - that is, the outer context, not the inner context. It then calls startCurrentItem and leaveCurrentItem for each item processed by the for-each.
 
I'm afraid I don't publish a build script. That's partly because I don't want to encourage people without the necessary skills to rebuild the product (I still get people who think they have to compile it before they can use it...), and partly because the scripts I use are very primitive and I've never got around to productizing them. If anyone has developed any ant scripts for building Saxon, I'd be interested.
 
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: 20 January 2005 14:15
To: saxon-help@lists.sourceforge.net
Subject: [saxon] another TraceListener Problem

Hi Mike!
Thanks for reporting this.I've recorded the bug at
 
 https://sourceforge.net/tracker/index.php?func=detail&aid=1105877&group_id=29872&atid=397617
 
where there is also a source fix if you want it.
Thank you for the fast reaction! I have an other problem. The same situation:
  class DebugTraceListener implements TraceListener {
    public void open() {}
    public void close() {}
    public void enter(InstructionInfo instruction, XPathContext context) {
      String name, sourcePath=null, scriptPath=null;
      int infotype = instruction.getConstructType();
      if(infotype < 1024)
        name = StandardNames.getDisplayName(infotype);
      else
        name = null;
      if(name!=null) {
        /* get the xpath of the script command */
        if(instruction instanceof StyleElement) {
          StyleElement styleElement = (StyleElement) instruction;
          scriptPath = Navigator.getPath(styleElement);
        }
        /* get the xpath of the source node */
        Item item = context.getContextItem();
        if(item instanceof NodeInfo) {
          NodeInfo nodeInfo = (NodeInfo) item;
          sourcePath = Navigator.getPath(nodeInfo);
        }
        System.out.println(scriptPath+" : "+sourcePath);
      }
    }
    public void leave(InstructionInfo instruction) {}
    public void startCurrentItem(Item item) {}
    public void endCurrentItem(Item currentItem) {}
  }

My Output is:

/xsl:stylesheet/xsl:template[1]/root[1]/xsl:for-each[1] : /
/xsl:stylesheet/xsl:template[1]/root[1]/xsl:for-each[1]/data[1]/xsl:value-of[1] : /Bestellung/Waren[1]
/xsl:stylesheet/xsl:template[1]/root[1]/xsl:apply-templates[1] : /
/xsl:stylesheet/xsl:template[2]/Book[1]/xsl:value-of[1] : /Bestellung/Waren[1]/Buch[1]
/xsl:stylesheet/xsl:template[2]/Book[1]/xsl:value-of[1] : /Bestellung/Waren[1]/Buch[2]

At the first line of the output - why do I get only the '/' as the source path?

The for-each has 'Bestellung/*[starts-with(name(),'W')]' as the xpath and works with this on the source path 'Bestellung/Waren[1]'.

An other question: How could I best build a version with a changes source file? Is there a build.xml or something? Is there a cvs for the 8.2 version?

Many thanx!
-- 
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