1 21 22 package nu.xom.samples; 23 24 import nu.xom.Comment; 25 import nu.xom.DocType; 26 import nu.xom.Document; 27 import nu.xom.Element; 28 import nu.xom.ProcessingInstruction; 29 import nu.xom.Text; 30 import nu.xom.XMLException; 31 32 44 public class SimpleSVG { 45 46 public static void main(String [] args) { 47 48 try { 49 DocType svgDOCTYPE = new DocType( 51 "svg", "-//W3C//DTD SVG 1.0//EN", 52 "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" 53 ); 54 55 Element root = new Element("svg", 57 "http://www.w3.org/2000/svg"); 58 Document doc = new Document(root); 59 doc.insertChild(svgDOCTYPE, 0); 60 ProcessingInstruction xmlstylesheet = new ProcessingInstruction("xml-stylesheet", 61 "type=\"text/css\" HREF=\"standard.css\""); 62 doc.insertChild(xmlstylesheet, 0); 63 Comment comment = new Comment( 64 "An example from Chapter 10 of Processing XML with Java"); 65 doc.insertChild(comment, doc.indexOf(root)); 66 Element desc = new Element("desc", "http://www.w3.org/2000/svg"); 67 root.appendChild(desc); 68 Text descText = new Text("An example from Processing XML with Java"); 69 desc.appendChild(descText); 70 71 System.out.println(doc.toXML()); 73 74 } 75 catch (XMLException ex) { 76 System.err.println(ex); 77 } 78 79 } 80 81 } 82 83 | Popular Tags |