1 package com.icl.saxon.output; 2 import com.icl.saxon.charcode.UnicodeCharacterSet; 3 import java.io.IOException ; 4 import org.xml.sax.Attributes ; 5 import javax.xml.transform.OutputKeys ; 6 import javax.xml.transform.TransformerException ; 7 8 12 13 public class TEXTEmitter extends XMLEmitter { 14 15 19 private String mediaType = "text/plain"; 20 21 24 25 public void startDocument () throws TransformerException 26 { 27 String mime = outputProperties.getProperty(OutputKeys.MEDIA_TYPE); 28 if (mime!=null) { 29 mediaType = mime; 30 } 31 32 if (characterSet==null) { 33 characterSet = UnicodeCharacterSet.getInstance(); 34 } 35 empty = true; 36 } 37 38 46 47 public void characters(char ch[], int start, int length) throws TransformerException { 48 for (int i=start; i<start+length; i++) { 49 if (!characterSet.inCharset(ch[i])) { 50 throw new TransformerException ("Output character not available in this encoding (decimal " + (int)ch[i] + ")"); 51 } 52 } 53 try { 54 writer.write(ch, start, length); 55 } catch (java.io.IOException err) { 56 throw new TransformerException (err); 57 } 58 } 59 60 65 66 public void startElement(int nameCode, Attributes attributes, 67 int[] namespaces, int nscount) throws TransformerException { 68 } 70 71 72 77 78 public void endElement(int nameCode) throws TransformerException { 79 } 81 82 86 87 public void processingInstruction(String name, String value) throws TransformerException {} 88 89 93 94 public void comment(char ch[], int start, int length) throws TransformerException {} 95 96 } 97 98 | Popular Tags |