/* * Creator.java * * Created on den 9 september 2001, 12:11 */ package ip1.u5.c; import org.jdom.*; import org.jdom.output.*; import java.io.*; /** * * @author h&m * @version */ public class Creator { /** Creates new Creator */ public Creator(String fileName) { Document doc = createDocument(); //skapar dokumentet XMLOutputter output = new XMLOutputter(" ", true); output.setTextNormalize(true); try{ output.output(doc, new FileWriter(fileName)); //skriver dokumentet till filen fileName } catch(IOException e) { System.out.println(e.getMessage()); } } private Document createDocument() { try { Element root = new Element("addressbook"); DocType dtd = new DocType("addressbook", "adressbok.dtd"); Document doc = new Document(root, dtd); root.addContent( (new Element("card")).addContent( (new Element("name")).addContent( (new Element("first")).addContent("Henrik")).addContent( (new Element("last")).addContent("Johansson"))).addContent( (new Element("addresses")).addContent( (new Element("swedish")).addContent( (new Element("street")).addContent("Sockenvägen 364")).addContent( (new Element("postalCode")).addContent("122 63")).addContent( (new Element("postalAddress")).addContent("Enskede")))).addContent( (new Element("work")).addContent( (new Element("title")).addContent("Sjukvårdsbiträde")).addContent( (new Element("department")).addContent("3e")).addContent( (new Element("organization")).addContent("Hogdalens äldreboende"))).addContent( (new Element("internet")).addContent( (new Element("inet-private")).addContent( (new Element("email")).addContent("henrik-j@dsv.su.se")).addContent( (new Element("email")).addContent("henrik.johansson1@telia.com")).addContent( (new Element("website")).addContent("http://www.geocities.com/bostadbytes")))).addContent( (new Element("phones")).addContent( (new Element("phones-private")).addContent( (new Element("phone")).addContent( (new Element("countrycode")).addContent("0046")).addContent( (new Element("areacode")).addContent("08")).addContent( (new Element("number")).addContent("7259997")).addContent( (new Element("comment")).addContent("om det inte är akut efter klockan 14:00 pga nattarbete.")))).addContent( (new Element("phones-work")).addContent( (new Element("phone")).addContent( (new Element("number")).addContent("50820612")).addContent( (new Element("comment")).addContent("Hogdalens äldreboende avdelning 3e"))).addContent( (new Element("phone")).addContent( (new Element("number")).addContent("50820613")).addContent( (new Element("comment")).addContent("Hogdalens äldreboende avdelning 3f")))))); return doc; } catch(IllegalAddException e) { System.out.println(e.getMessage()); } return null; } /** * @param args the command line arguments */ public static void main (String args[]) { new Creator(args[0]); } }