diff --git a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class
deleted file mode 100644
index aecafafbf..000000000
Binary files a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.class and /dev/null differ
diff --git a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java
index b95de46b5..45fee57fc 100644
--- a/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java
+++ b/java/com/jenitennison/xslt/tests/XSLTCoverageTraceListener.java
@@ -1,18 +1,19 @@
/****************************************************************************/
/* File: XSLTCoverageTraceListener.java */
/* Author: Jeni Tennsion */
-/* URI: http://xspec.googlecode.com/ */
+/* URI: https://github.com/innovimax/xspec */
/* Tags: */
-/* Copyright (c) 2008, 2010 (see end of file.) */
+/* Copyright (c) 2008, 2010, 2017 (see end of file.) */
/* ------------------------------------------------------------------------ */
-
package com.jenitennison.xslt.tests;
-import net.sf.saxon.trace.TraceListener;
import net.sf.saxon.trace.InstructionInfo;
-import net.sf.saxon.trace.Location;
+import net.sf.saxon.trace.LocationKind;
+import net.sf.saxon.Controller;
import net.sf.saxon.expr.XPathContext;
+import net.sf.saxon.lib.Logger;
+import net.sf.saxon.lib.TraceListener;
import net.sf.saxon.om.Item;
import net.sf.saxon.om.StandardNames;
import java.lang.String;
@@ -21,160 +22,187 @@
import java.io.PrintStream;
/**
- * A Simple trace listener for XSLT that writes messages (by default) to System.err
+ * A Simple trace listener for XSLT that writes messages (by default) to
+ * System.err
*/
public class XSLTCoverageTraceListener implements TraceListener {
- private PrintStream out = System.err;
- private String xspecStylesheet = null;
- private String utilsStylesheet = null;
- private HashMap modules = new HashMap();
- private HashSet constructs = new HashSet();
- private int moduleCount = 0;
-
- /**
- * Method called at the start of execution, that is, when the run-time transformation starts
- */
-
- public void open() {
- out.println("");
- }
-
- /**
- * Method called at the end of execution, that is, when the run-time execution ends
- */
-
- public void close() {
- out.println("");
- }
-
- /**
- * Method that is called when an instruction in the stylesheet gets processed.
- * @param instruction gives information about the instruction being
- * executed, and about the context in which it is executed. This object is mutable,
- * so if information from the InstructionInfo is to be retained, it must be copied.
- */
-
- public void enter(InstructionInfo info, XPathContext context) {
- int lineNumber = info.getLineNumber();
- String systemId = info.getSystemId();
- int constructType = info.getConstructType();
- if (utilsStylesheet == null &&
- systemId.indexOf("generate-tests-utils.xsl") != -1) {
- utilsStylesheet = systemId;
- out.println("");
- } else if (xspecStylesheet == null &&
- systemId.indexOf("/xspec/") != -1) {
- xspecStylesheet = systemId;
- out.println("");
- }
- if (systemId != xspecStylesheet && systemId != utilsStylesheet) {
- Integer module;
- if (modules.containsKey(systemId)) {
- module = (Integer)modules.get(systemId);
- } else {
- module = new Integer(moduleCount);
- moduleCount += 1;
- modules.put(systemId, module);
- out.println("");
- }
- if (!constructs.contains(constructType)) {
- String construct;
- if (constructType < 1024) {
- construct = StandardNames.getClarkName(constructType);
- } else {
- switch (constructType) {
- case Location.LITERAL_RESULT_ELEMENT:
- construct = "LITERAL_RESULT_ELEMENT";
- break;
- case Location.LITERAL_RESULT_ATTRIBUTE:
- construct = "LITERAL_RESULT_ATTRIBUTE";
- break;
- case Location.EXTENSION_INSTRUCTION:
- construct = "EXTENSION_INSTRUCTION";
- break;
- case Location.TEMPLATE:
- construct = "TEMPLATE";
- break;
- case Location.FUNCTION_CALL:
- construct = "FUNCTION_CALL";
- break;
- case Location.BUILT_IN_TEMPLATE:
- construct = "BUILT_IN_TEMPLATE";
- break;
- case Location.XPATH_IN_XSLT:
- construct = "XPATH_IN_XSLT";
- break;
- case Location.LET_EXPRESSION:
- construct = "LET_EXPRESSION";
- break;
- case Location.TRACE_CALL:
- construct = "TRACE_CALL";
- break;
- case Location.SAXON_EVALUATE:
- construct = "SAXON_EVALUATE";
- break;
- case Location.FUNCTION:
- construct = "FUNCTION";
- break;
- case Location.XPATH_EXPRESSION:
- construct = "XPATH_EXPRESSION";
- break;
- default:
- construct = "Other";
- }
- }
- constructs.add(constructType);
- out.println("");
- }
- out.println("");
- }
- }
-
- /**
- * Method that is called after processing an instruction of the stylesheet,
- * that is, after any child instructions have been processed.
- * @param instruction gives the same information that was supplied to the
- * enter method, though it is not necessarily the same object. Note that the
- * line number of the instruction is that of the start tag in the source stylesheet,
- * not the line number of the end tag.
- */
-
- public void leave(InstructionInfo instruction) {
- // Do nothing
- }
-
- /**
- * Method that is called by an instruction that changes the current item
- * in the source document: that is, xsl:for-each, xsl:apply-templates, xsl:for-each-group.
- * The method is called after the enter method for the relevant instruction, and is called
- * once for each item processed.
- * @param currentItem the new current item. Item objects are not mutable; it is safe to retain
- * a reference to the Item for later use.
- */
-
- public void startCurrentItem(Item currentItem) {
- // Do nothing
- }
-
- /**
- * Method that is called when an instruction has finished processing a new current item
- * and is ready to select a new current item or revert to the previous current item.
- * The method will be called before the leave() method for the instruction that made this
- * item current.
- * @param currentItem the item that was current, whose processing is now complete. This will represent
- * the same underlying item as the corresponding startCurrentItem() call, though it will
- * not necessarily be the same actual object.
- */
-
- public void endCurrentItem(Item currentItem) {
- // Do nothing
- }
+ private PrintStream out = System.err;
+ private String xspecStylesheet = null;
+ private String utilsStylesheet = null;
+ private HashMap modules = new HashMap();
+ private HashSet constructs = new HashSet();
+ private int moduleCount = 0;
+
+ /**
+ * Method called at the start of execution, that is, when the run-time
+ * transformation starts
+ */
+
+ public void open() {
+ this.out.println("");
+ }
+
+ /**
+ * Method called at the end of execution, that is, when the run-time
+ * execution ends
+ */
+
+ @Override
+ public void close() {
+ this.out.println("");
+ }
+
+ /**
+ * Method that is called when an instruction in the stylesheet gets
+ * processed.
+ *
+ * @param instruction
+ * gives information about the instruction being executed, and
+ * about the context in which it is executed. This object is
+ * mutable, so if information from the InstructionInfo is to be
+ * retained, it must be copied.
+ */
+
+ @Override
+ public void enter(InstructionInfo info, XPathContext context) {
+ int lineNumber = info.getLineNumber();
+ String systemId = info.getSystemId();
+ int constructType = info.getConstructType();
+ if (this.utilsStylesheet == null && systemId.indexOf("generate-tests-utils.xsl") != -1) {
+ this.utilsStylesheet = systemId;
+ this.out.println("");
+ } else if (this.xspecStylesheet == null && systemId.indexOf("/xspec/") != -1) {
+ this.xspecStylesheet = systemId;
+ this.out.println("");
+ }
+ if (systemId != this.xspecStylesheet && systemId != this.utilsStylesheet) {
+ Integer module;
+ if (this.modules.containsKey(systemId)) {
+ module = this.modules.get(systemId);
+ } else {
+ module = new Integer(this.moduleCount);
+ this.moduleCount += 1;
+ this.modules.put(systemId, module);
+ this.out.println("");
+ }
+ if (!this.constructs.contains(constructType)) {
+ String construct;
+ if (constructType < 1024) {
+ construct = StandardNames.getClarkName(constructType);
+ } else {
+ switch (constructType) {
+ case LocationKind.LITERAL_RESULT_ELEMENT:
+ construct = "LITERAL_RESULT_ELEMENT";
+ break;
+ case LocationKind.LITERAL_RESULT_ATTRIBUTE:
+ construct = "LITERAL_RESULT_ATTRIBUTE";
+ break;
+ case LocationKind.EXTENSION_INSTRUCTION:
+ construct = "EXTENSION_INSTRUCTION";
+ break;
+ case LocationKind.TEMPLATE:
+ construct = "TEMPLATE";
+ break;
+ case LocationKind.FUNCTION_CALL:
+ construct = "FUNCTION_CALL";
+ break;
+ // case LocationKind.BUILT_IN_TEMPLATE:
+ // construct = "BUILT_IN_TEMPLATE";
+ // break;
+ case LocationKind.XPATH_IN_XSLT:
+ construct = "XPATH_IN_XSLT";
+ break;
+ case LocationKind.LET_EXPRESSION:
+ construct = "LET_EXPRESSION";
+ break;
+ case LocationKind.TRACE_CALL:
+ construct = "TRACE_CALL";
+ break;
+ case LocationKind.SAXON_EVALUATE:
+ construct = "SAXON_EVALUATE";
+ break;
+ case LocationKind.FUNCTION:
+ construct = "FUNCTION";
+ break;
+ case LocationKind.XPATH_EXPRESSION:
+ construct = "XPATH_EXPRESSION";
+ break;
+ default:
+ construct = "Other";
+ }
+ }
+ this.constructs.add(constructType);
+ this.out.println("");
+ }
+ this.out.println("");
+ }
+ }
+
+ /**
+ * Method that is called after processing an instruction of the stylesheet,
+ * that is, after any child instructions have been processed.
+ *
+ * @param instruction
+ * gives the same information that was supplied to the enter
+ * method, though it is not necessarily the same object. Note
+ * that the line number of the instruction is that of the start
+ * tag in the source stylesheet, not the line number of the end
+ * tag.
+ */
+
+ @Override
+ public void leave(InstructionInfo instruction) {
+ // Do nothing
+ }
+
+ /**
+ * Method that is called by an instruction that changes the current item in
+ * the source document: that is, xsl:for-each, xsl:apply-templates,
+ * xsl:for-each-group. The method is called after the enter method for the
+ * relevant instruction, and is called once for each item processed.
+ *
+ * @param currentItem
+ * the new current item. Item objects are not mutable; it is safe
+ * to retain a reference to the Item for later use.
+ */
+
+ @Override
+ public void startCurrentItem(Item currentItem) {
+ // Do nothing
+ }
+
+ /**
+ * Method that is called when an instruction has finished processing a new
+ * current item and is ready to select a new current item or revert to the
+ * previous current item. The method will be called before the leave()
+ * method for the instruction that made this item current.
+ *
+ * @param currentItem
+ * the item that was current, whose processing is now complete.
+ * This will represent the same underlying item as the
+ * corresponding startCurrentItem() call, though it will not
+ * necessarily be the same actual object.
+ */
+
+ @Override
+ public void endCurrentItem(Item currentItem) {
+ // Do nothing
+ }
+
+ @Override
+ public void open(Controller arg0) {
+ // Do nothing
+ }
+
+ @Override
+ public void setOutputDestination(Logger arg0) {
+ // Do nothing
+ }
}
-
//
// The contents of this file are subject to the Mozilla Public License
// Version 1.0 (the "License"); you may not use this file except in
@@ -195,5 +223,6 @@ public void endCurrentItem(Item currentItem) {
// All Rights Reserved.
//
// Contributor(s): Heavily modified by Michael Kay
-// Methods implemented by Jeni Tennison
+// updated to Saxon 9.7 by Mohamed Zergaoui (Innovimax)
+// Methods implemented by Jeni Tennison
//