1 package net.sf.saxon.pull; 2 3 import net.sf.saxon.trans.XPathException; 4 5 9 10 public class PullTracer extends PullFilter { 11 12 16 17 public PullTracer(PullProvider base) { 18 super(base); 19 } 20 21 28 29 public int next() throws XPathException { 30 currentEvent = super.next(); 31 traceEvent(currentEvent); 32 return currentEvent; 33 } 34 35 36 39 40 private void traceEvent(int event) { 41 PullProvider in = getUnderlyingProvider(); 42 switch (event) { 43 case START_DOCUMENT: 44 System.err.println("START_DOCUMENT"); 45 break; 46 47 case START_ELEMENT: 48 System.err.println("START_ELEMENT " + in.getNameCode()); 49 break; 50 51 case TEXT: 52 System.err.println("TEXT"); 53 break; 54 55 case COMMENT: 56 System.err.println("COMMENT"); 57 break; 58 59 case PROCESSING_INSTRUCTION: 60 System.err.println("PROCESSING_INSTRUCTION"); 61 break; 62 63 case END_ELEMENT: 64 System.err.println("END_ELEMENT " + in.getNameCode()); 65 break; 66 67 case END_DOCUMENT: 68 System.err.println("END_DOCUMENT"); 69 break; 70 71 case END_OF_INPUT: 72 System.err.println("END_OF_INPUT"); 73 break; 74 75 case ATOMIC_VALUE: 76 try { 77 System.err.println("ATOMIC VALUE: " + in.getStringValue()); 78 } catch (XPathException e) { 79 } 81 } 82 } 83 } 84 85 | Popular Tags |