[Aimmath-commit] AIM/WEB-INF/java/tth TtH.java,1.4,1.4.4.1
Brought to you by:
gustav_delius,
npstrick
From: Neil S. <nps...@us...> - 2005-03-10 21:16:16
|
Update of /cvsroot/aimmath/AIM/WEB-INF/java/tth In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4631/java/tth Modified Files: Tag: aim-xml TtH.java Log Message: Index: TtH.java =================================================================== RCS file: /cvsroot/aimmath/AIM/WEB-INF/java/tth/TtH.java,v retrieving revision 1.4 retrieving revision 1.4.4.1 diff -C2 -d -r1.4 -r1.4.4.1 *** TtH.java 1 Sep 2003 20:22:23 -0000 1.4 --- TtH.java 10 Mar 2005 21:16:00 -0000 1.4.4.1 *************** *** 16,19 **** --- 16,27 ---- import java.io.*; import java.util.*; + import org.w3c.dom.Attr; + import org.w3c.dom.Document; + import org.w3c.dom.NamedNodeMap; + import org.w3c.dom.Node; + import org.w3c.dom.NodeList; + import org.apache.xerces.parsers.DOMParser; + import org.xml.sax.InputSource; + import org.xml.sax.SAXException; public class TtH { *************** *** 221,224 **** --- 229,267 ---- return(html); } + + public static void convertXML(Document doc,String opt) + throws Exception { + convertXML(doc,doc,opt); + } + + public static void convertXML(Document doc,Node node,String opt) + throws Exception { + int type = node.getNodeType(); + if (type == Node.ELEMENT_NODE) { + NamedNodeMap nnm = node.getAttributes(); + if (nnm != null && nnm.getNamedItem("convertLaTeX") != null) { + nnm.removeNamedItem("convertLaTeX"); + String s = ""; + while (node.hasChildNodes()) { + Node c = node.getFirstChild(); + node.removeChild(c); + if (c.getNodeType() == Node.TEXT_NODE) { + s += c.getNodeValue(); + } else { + throw new Exception("Non-text node"); + } + } + s = convert(s,opt); + node.appendChild(doc.createTextNode(s)); + } + } + + //recurse + for(Node child = node.getFirstChild(); + child != null; + child = child.getNextSibling()) { + convertXML(doc,child,opt); + } + } } |