6.5 Hyper Complex Fractions
NodeList children = node.getChildNodes();
int max = 0;
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
int d = setFracLevel(child,
(clName != null) &&
clName.equals("continuous-mfrac")?
2 :
((clName != null) &&
clName.equals("continuous-mfrac")?
(cont-1) : cont)
);
if (d > max) { max = d; }
} }
level += max;
-_-_-
The ‘cont’ parameter is for determining whether the parent and the grandparent
are frac elements marked as continuous.
if( clName.equals("msub") || clName.equals("msup") ||
clName.equals("msubsup")
) {
return 0;
}
-_-_-
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes()
.getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if (clsName.equals("begin-end")) {
child = child.getFirstChild();
String s = child.getNodeValue();
String bg = "", ov = "", en = "";
for(int j=0; j<level; j++){
bg += " begin "; ov += " over "; en += " end ";
}
s = s.replaceFirst("begin", bg + "begin");
s = s.replaceFirst("over", ov + "over");
s = s.replaceFirst("end", en + "end");
((org.w3c.dom.Text) child).setData(s);
} } } }
-_-_-
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes()
.getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if ( clsName.equals("begin-end")) {
child = child.getFirstChild();
String s = child.getNodeValue();
s = s.replaceFirst("begin", "begin continued");
s = s.replaceFirst("end", "end continued");
((org.w3c.dom.Text) child).setData(s);
} } } }
-_-_-
Node child = node.getLastChild();
if (child.getNodeType() == Node.ELEMENT_NODE) {
Node cls = child.getAttributes() .getNamedItem("class");
if (cls != null) {
String clsName = cls.getNodeValue();
if ( clsName.equals("begin-end")) {
node.removeChild( child );
} } }
-_-_-