1 21 22 package nu.xom.samples; 23 24 import java.math.BigInteger ; 25 26 import nu.xom.Document; 27 import nu.xom.Element; 28 29 41 public class MathMLFibonacci { 42 43 public static void main(String [] args) { 44 45 BigInteger low = BigInteger.ONE; 46 BigInteger high = BigInteger.ONE; 47 48 54 String namespace = "http://www.w3.org/1998/Math/MathML"; 55 Element root = new Element("mathml:math", namespace); 56 for (int i = 1; i <= 10; i++) { 57 Element mrow = new Element("mathml:mrow", namespace); 58 Element mi = new Element("mathml:mi", namespace); 59 Element mo = new Element("mathml:mo", namespace); 60 Element mn = new Element("mathml:mn", namespace); 61 mrow.appendChild(mi); 62 mrow.appendChild(mo); 63 mrow.appendChild(mn); 64 root.appendChild(mrow); 65 mi.appendChild("f(" + i + ")"); 66 mo.appendChild("="); 67 mn.appendChild(low.toString()); 68 69 BigInteger temp = high; 70 high = high.add(low); 71 low = temp; 72 } 73 Document doc = new Document(root); 74 System.out.println(doc.toXML()); 75 76 } 77 78 } | Popular Tags |