| 1 |
package tex4ht; |
| 2 |
import org.xml.sax.helpers.*; |
| 3 |
import org.xml.sax.*; |
| 4 |
import java.io.PrintWriter; |
| 5 |
|
| 6 |
public class GroupMn extends XMLFilterImpl { |
| 7 |
PrintWriter out = null; |
| 8 |
boolean inMn = false; |
| 9 |
String ns; |
| 10 |
int level = -1; |
| 11 |
public GroupMn( PrintWriter out, PrintWriter log, boolean trace){ |
| 12 |
this.out = out; |
| 13 |
} |
| 14 |
public void startElement(String ns, String sName, |
| 15 |
String qName, Attributes attr) { |
| 16 |
level++; |
| 17 |
try{ |
| 18 |
if( inMn ){ |
| 19 |
if( level == 0 ){ if( !qName.equals( "mn" ) ){ |
| 20 |
if( qName.equals( "mo" ) ){ |
| 21 |
String cls = attr.getValue( "class" ); |
| 22 |
if( (cls == null) || !cls.equals("MathClass-punc") ){ |
| 23 |
inMn = false; |
| 24 |
super.endElement(ns, "mn-group", "mn-group"); |
| 25 |
} |
| 26 |
} else { |
| 27 |
inMn = false; |
| 28 |
super.endElement(ns, "mn-group", "mn-group"); |
| 29 |
} } |
| 30 |
} |
| 31 |
} else { if( qName.equals( "mn" ) ){ |
| 32 |
inMn = true; level = 0; |
| 33 |
Attributes att = new AttributesImpl(); |
| 34 |
super.startElement(ns, "mn-group", "mn-group", att); |
| 35 |
this.ns = ns; |
| 36 |
} else if( qName.equals( "mo" ) ){ |
| 37 |
String cls = attr.getValue( "class" ); |
| 38 |
if( (cls != null) && cls.equals("MathClass-punc") ){ |
| 39 |
inMn = true; level = 0; |
| 40 |
Attributes att = new AttributesImpl(); |
| 41 |
super.startElement(ns, "mn-group", "mn-group", att); |
| 42 |
this.ns = ns; |
| 43 |
} } |
| 44 |
} |
| 45 |
super.startElement(ns, sName, qName, attr); |
| 46 |
} catch( Exception e ){ |
| 47 |
System.out.println( "--- GroupMn Error 1 --- " + e); |
| 48 |
} |
| 49 |
} |
| 50 |
public void endElement(String ns, String sName, String qName){ |
| 51 |
try{ |
| 52 |
if( level < 0) { |
| 53 |
if( inMn ){ |
| 54 |
inMn = false; |
| 55 |
super.endElement(ns, "mn-group", "mn-group"); |
| 56 |
} |
| 57 |
|
| 58 |
} |
| 59 |
super.endElement(ns, sName, qName); |
| 60 |
} catch( Exception e ){ |
| 61 |
System.out.println( "--- GroupMn Error 2 --- " + e); |
| 62 |
} |
| 63 |
level--; |
| 64 |
} |
| 65 |
public void characters(char[] ch, int start, int length){ |
| 66 |
try{ |
| 67 |
if ( inMn && (level < 0) ) { |
| 68 |
String s = new String(ch, start, length); |
| 69 |
if (!s.trim().equals("")) { |
| 70 |
inMn = false; |
| 71 |
super.endElement(ns, "mn-group", "mn-group"); |
| 72 |
} } |
| 73 |
super.characters(ch, start, length); |
| 74 |
} catch( Exception e ){ |
| 75 |
System.out.println( "--- GroupMn Error 3 --- " + e); |
| 76 |
} } } |
| 77 |
|