1
/* Copyright 2002-2004 Elliotte Rusty Harold
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of version 2.1 of the GNU Lesser General Public
5
License as published by the Free Software Foundation.
7
This library is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU Lesser General Public License for more details.
12
You should have received a copy of the GNU Lesser General Public
13
License along with this library; if not, write to the
14
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
15
Boston, MA 02111-1307 USA
17
You can contact Elliotte Rusty Harold by sending e-mail to
18
elharo@metalab.unc.edu. Please include the word "XOM" in the
19
subject line. The XOM home page is located at http://www.xom.nu/
22
package nu.xom.samples;
24
import java.math.BigInteger;
26
import nu.xom.Document;
27
import nu.xom.Element;
32
* Demonstrates the creation and serialization of a
34
* that uses namespaces and namespace prefixes.
37
* @author Elliotte Rusty Harold
41
public class MathMLFibonacci {
43
public static void main(String[] args) {
45
BigInteger low = BigInteger.ONE;
46
BigInteger high = BigInteger.ONE;
48
/* <mathml:math xmlns:mathml="http://www.w3.org/1998/Math/MathML">
50
<mathml:mi>f(1)</mathml:mi>
51
<mathml:mo>=</mathml:mo>
52
<mathml:mn>1</mathml:mn>
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);
64
root.appendChild(mrow);
65
mi.appendChild("f(" + i + ")");
67
mn.appendChild(low.toString());
69
BigInteger temp = high;
73
Document doc = new Document(root);
74
System.out.println(doc.toXML());
b'\\ No newline at end of file'