List of usage examples for org.dom4j.tree DefaultElement DefaultElement
public DefaultElement(String name, Namespace namespace)
From source file:de.saar.coli.salsa.reiter.framenet.Frame.java
License:Open Source License
public Element exportToSalsaTiger() { Namespace ns = new Namespace("fd", "http://www.clt-st.de/framenet/frame-database"); Element elem = new DefaultElement("frame", ns); elem.add(new FlyweightAttribute("name", this.getName(), ns)); for (FrameElement fe : this.frameElements()) { Element fee = new DefaultElement("element", ns); fee.add(new FlyweightAttribute("name", fe.getName(), ns)); fee.add(new FlyweightAttribute("optional", String.valueOf(!fe.isCore()), ns)); elem.add(fee);//from ww w . j av a 2 s . c om } return elem; }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createAuthEl(String name, String authenticationText) { if (name == null) { throw new NullPointerException("SASL mechanism name shouldn't be null."); }//from w w w .j av a2s . c o m DefaultElement authEl = new DefaultElement("auth", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); authEl.addAttribute("mechanism", name); if (authenticationText != null) { authEl.setText(authenticationText); } return authEl; }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createChallengeEl(String data) { DefaultElement authEl = new DefaultElement("challenge", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); if (data != null) { authEl.setText(data);/*from w ww . ja v a 2 s . c o m*/ } return authEl; }
From source file:org.jivesoftware.smack.sasl.SASLMechanism.java
License:Open Source License
private static Element createResponseEl(String authenticationText) { DefaultElement authEl = new DefaultElement("response", Namespace.get("urn:ietf:params:xml:ns:xmpp-sasl")); if (authenticationText != null && !authenticationText.isEmpty()) { authEl.setText(authenticationText); }/* www . j a v a 2 s .c om*/ return authEl; }
From source file:org.opensha.commons.geo.RegionUtils.java
License:Apache License
public static void regionToKML(Region region, String filename, Color c) { String kmlFileName = filename + ".kml"; Document doc = DocumentHelper.createDocument(); Element root = new DefaultElement("kml", new Namespace("", "http://www.opengis.net/kml/2.2")); doc.add(root);//from w w w .ja v a 2s . c o m Element e_doc = root.addElement("Document"); Element e_doc_name = e_doc.addElement("name"); e_doc_name.addText(kmlFileName); addBorderStyle(e_doc, c); addBorderVertexStyle(e_doc); addGridNodeStyle(e_doc, c); Element e_folder = e_doc.addElement("Folder"); Element e_folder_name = e_folder.addElement("name"); e_folder_name.addText("region"); Element e_open = e_folder.addElement("open"); e_open.addText("1"); addBorder(e_folder, region); addPoints(e_folder, "Border Nodes", region.getBorder(), Style.BORDER_VERTEX); if (region.getInteriors() != null) { for (LocationList interior : region.getInteriors()) { addPoints(e_folder, "Interior Nodes", interior, Style.BORDER_VERTEX); } } if (region instanceof GriddedRegion) { addPoints(e_folder, "Grid Nodes", ((GriddedRegion) region).getNodeList(), Style.GRID_NODE); } // TODO absolutely need to create seom platform specific output directory // that is not in project space (e.g. desktop, Decs and Settings); String outDirName = "sha_kml/"; File outDir = new File(outDirName); outDir.mkdirs(); String tmpFile = outDirName + kmlFileName; try { //XMLUtils.writeDocumentToFile(tmpFile, doc); XMLWriter writer; OutputFormat format = new OutputFormat("\t", true); writer = new XMLWriter(new FileWriter(tmpFile), format); writer.write(doc); writer.close(); } catch (IOException ioe) { ioe.printStackTrace(); } //Element e = new Elem }
From source file:org.opensha.commons.geo.RegionUtils.java
License:Apache License
public static void locListToKML(LocationList locs, String filename, Color c) { String kmlFileName = filename + ".kml"; Document doc = DocumentHelper.createDocument(); Element root = new DefaultElement("kml", new Namespace("", "http://www.opengis.net/kml/2.2")); doc.add(root);/*from w ww . ja v a 2s .c o m*/ Element e_doc = root.addElement("Document"); Element e_doc_name = e_doc.addElement("name"); e_doc_name.addText(kmlFileName); addBorderStyle(e_doc, c); addBorderVertexStyle(e_doc); addGridNodeStyle(e_doc, c); Element e_folder = e_doc.addElement("Folder"); Element e_folder_name = e_folder.addElement("name"); e_folder_name.addText("region"); Element e_open = e_folder.addElement("open"); e_open.addText("1"); // addLocationPoly(e_folder, locs); addLocationLine(e_folder, locs); addPoints(e_folder, "Border Nodes", locs, Style.BORDER_VERTEX); // TODO absolutely need to create seom platform specific output directory // that is not in project space (e.g. desktop, Decs and Settings); String outDirName = "sha_kml/"; File outDir = new File(outDirName); outDir.mkdirs(); String tmpFile = outDirName + kmlFileName; try { //XMLUtils.writeDocumentToFile(tmpFile, doc); XMLWriter writer; OutputFormat format = new OutputFormat("\t", true); writer = new XMLWriter(new FileWriter(tmpFile), format); writer.write(doc); writer.close(); } catch (IOException ioe) { ioe.printStackTrace(); } //Element e = new Elem }