001: package net.sf.saxon.trace;
002:
003: import net.sf.saxon.style.StandardNames;
004:
005: /**
006: * A Simple trace listener for XQuery that writes messages (by default) to System.err
007: */
008:
009: public class XQueryTraceListener extends AbstractTraceListener {
010:
011: /**
012: * Generate attributes to be included in the opening trace element
013: */
014:
015: protected String getOpeningAttributes() {
016: return "";
017: }
018:
019: /**
020: * Get the trace element tagname to be used for a particular construct. Return null for
021: * trace events that are ignored by this trace listener.
022: */
023:
024: protected String tag(int construct) {
025: switch (construct) {
026: case StandardNames.XSL_FUNCTION:
027: return "function";
028: case StandardNames.XSL_VARIABLE:
029: return "variable";
030: case StandardNames.XSL_ELEMENT:
031: return "element";
032: case StandardNames.XSL_ATTRIBUTE:
033: return "attribute";
034: case StandardNames.XSL_COMMENT:
035: return "comment";
036: case StandardNames.XSL_DOCUMENT:
037: return "document";
038: case StandardNames.XSL_PROCESSING_INSTRUCTION:
039: return "processing-instruction";
040: case StandardNames.XSL_TEXT:
041: return "text";
042: case StandardNames.XSL_NAMESPACE:
043: return "namespace";
044: case Location.LITERAL_RESULT_ELEMENT:
045: return "element";
046: case Location.LITERAL_RESULT_ATTRIBUTE:
047: return "attribute";
048: case Location.FUNCTION_CALL:
049: //return "function-call";
050: return null;
051: case Location.FOR_EXPRESSION:
052: return "for";
053: case Location.LET_EXPRESSION:
054: return "let";
055: case Location.WHERE_CLAUSE:
056: return "where";
057: case Location.ORDER_BY_CLAUSE:
058: return "sort";
059: case Location.RETURN_EXPRESSION:
060: return "return";
061: case Location.TYPESWITCH_EXPRESSION:
062: return "typeswitch";
063: case Location.VALIDATE_EXPRESSION:
064: return "validate";
065: case Location.IF_EXPRESSION:
066: return "if";
067: case Location.THEN_EXPRESSION:
068: return "then";
069: case Location.ELSE_EXPRESSION:
070: return "else";
071: case Location.CASE_EXPRESSION:
072: return "case";
073: case Location.DEFAULT_EXPRESSION:
074: return "default";
075: case Location.TRACE_CALL:
076: return "user-trace";
077: default:
078: //return "Other";
079: return null;
080: }
081: }
082:
083: }
084:
085: //
086: // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
087: // you may not use this file except in compliance with the License. You may obtain a copy of the
088: // License at http://www.mozilla.org/MPL/
089: //
090: // Software distributed under the License is distributed on an "AS IS" basis,
091: // WITHOUT WARRANTY OF ANY KIND, either express or implied.
092: // See the License for the specific language governing rights and limitations under the License.
093: //
094: // The Original Code is: all this file.
095: //
096: // The Initial Developer of the Original Code is Michael H. Kay
097: //
098: // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
099: //
100: // Contributor(s): none
101: //
|