import org.xml.sax.*; import org.xml.sax.helpers.*; public class ProcessingInstructionConverter extends XMLFilterImpl { public void processingInstruction(String target, String data) throws SAXException { // AttributesImpl is an adapter class in the org.xml.sax.ext package // for precisely this case. We don't really want to add any attributes // here, but we need to pass something as the fourth argument to // startElement(). Attributes emptyAttributes = new AttributesImpl(); // We won't use any namespace for the element startElement("", target, target, emptyAttributes); // converts String data to char array char[] text = data.toCharArray(); characters(text, 0, text.length); endElement("", target, target); } }