1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package tex4ht;
/*
JsmlMathBreak.java (2007-09-01-14:10)
*/
import xtpipes.XtpipesUni;
import org.xml.sax.*;
import org.xml.sax.helpers.DefaultHandler;
import java.io.*;
import java.lang.reflect.*;
import java.util.HashMap;
public class JsmlMathBreak extends DefaultHandler {
PrintWriter out = null;
boolean delete = false;
public JsmlMathBreak(PrintWriter out,
HashMap<String,Object> scripts,
Method method, PrintWriter log, boolean trace) {
this.out = out;
}
public void characters(char[] ch, int start, int length) {
String s = XtpipesUni.toUni(ch, start, length, "<>&");
out.print( s );
if( !s.trim().equals("") ){
delete = false;
} }
public void startElement(String ns, String sName,
String qName,
Attributes atts) {
if( !( delete && qName.equals("BREAK") ) ){
String s = "<" + qName + "\n";
for (int i = 0; i < atts.getLength(); i++) {
String name = atts.getQName(i);
if (name != "xmlns") {
s += (" " + name + "=\""
+ XtpipesUni.toUni(atts.getValue(i), "<>&\"")
+ "\"");
} }
if( qName.equals( "BREAK" ) ){
s += "/";
delete = true;
}
s += ">";
out.print(s);
} }
public void endElement(String ns, String sName, String qName) {
if( !qName.equals( "BREAK" ) ){
String s = "</" + qName + ">";
out.print(s);
} } }
|