1 package net.sf.saxon.event; 2 3 import net.sf.saxon.trans.XPathException; 4 import net.sf.saxon.om.FastStringBuffer; 5 6 11 12 13 public class CommentStripper extends ProxyReceiver { 14 15 private FastStringBuffer buffer = new FastStringBuffer(200); 16 17 20 21 public CommentStripper() {} 22 23 24 public void startElement (int nameCode, int typeCode, int locationId, int properties) 25 throws XPathException { 26 flush(); 27 super.startElement(nameCode, typeCode, locationId, properties); 28 } 29 30 33 34 public void endElement () throws XPathException { 35 flush(); 36 super.endElement(); 37 } 38 39 42 43 public void characters (CharSequence chars, int locationId, int properties) throws XPathException { 44 buffer.append(chars); 45 } 46 47 50 51 public void comment (CharSequence chars, int locationId, int properties) {} 52 53 56 57 public void processingInstruction(String name, CharSequence data, int locationId, int properties) {} 58 59 62 63 private void flush() throws XPathException { 64 super.characters(buffer, 0, 0); 65 buffer.setLength(0); 66 } 67 68 } 69 70 | Popular Tags |