List of usage examples for org.w3c.dom Element setAttribute
public void setAttribute(String name, String value) throws DOMException;
From source file:de.erdesignerng.model.serializer.xml10.XMLSubjectAreaSerializer.java
@Override public void serialize(SubjectArea aArea, Document aDocument, Element aRootElement) { Element theSubjectAreaElement = addElement(aDocument, aRootElement, SUBJECTAREA); // Basisdaten des Modelelementes speichern serializeProperties(aDocument, theSubjectAreaElement, aArea); theSubjectAreaElement.setAttribute(COLOR, "" + aArea.getColor().getRGB()); for (Table theTable : aArea.getTables()) { Element theTableElement = addElement(aDocument, theSubjectAreaElement, ITEM); theTableElement.setAttribute(TABLEREFID, theTable.getSystemId()); }/*from w w w . j av a 2s. c o m*/ for (Comment theComment : aArea.getComments()) { Element theCommentElement = addElement(aDocument, theSubjectAreaElement, ITEM); theCommentElement.setAttribute(COMMENTREFID, theComment.getSystemId()); } }
From source file:de.erdesignerng.model.serializer.xml30.XMLAttributeSerializer.java
@Override public void serialize(Attribute aAttribute, Document aDocument, Element aRootElement) { Element theAttributeElement = addElement(aDocument, aRootElement, ATTRIBUTE); // Basisdaten des Modelelementes speichern serializeProperties(aDocument, theAttributeElement, aAttribute); theAttributeElement.setAttribute(DATATYPE, "" + ((aAttribute.getDatatype() != null) ? aAttribute.getDatatype().getName() : "")); // Bug Fixing 2876916 [ERDesignerNG] Reverse-Eng. PgSQL VARCHAR max-length wrong theAttributeElement.setAttribute(SIZE, "" + ((aAttribute.getSize() != null) ? aAttribute.getSize() : "")); theAttributeElement.setAttribute(FRACTION, "" + aAttribute.getFraction()); theAttributeElement.setAttribute(SCALE, "" + aAttribute.getScale()); theAttributeElement.setAttribute(DEFAULTVALUE, aAttribute.getDefaultValue()); theAttributeElement.setAttribute(EXTRA, aAttribute.getExtra()); setBooleanAttribute(theAttributeElement, NULLABLE, aAttribute.isNullable()); serializeCommentElement(aDocument, theAttributeElement, aAttribute); }
From source file:com.twinsoft.convertigo.engine.AttachmentManager.java
public void addAttachment(final byte[] data, final String name, final String contentType, String referer, String url, Policy policy, String filename, Status status) { Element eAttachment = transaction.context.outputDocument.createElement("attachment"); eAttachment.setAttribute("type", "attachment"); eAttachment.setAttribute("name", name); eAttachment.setAttribute("content-type", contentType); if (referer != null) { eAttachment.setAttribute("referer", referer); }//from ww w . j a v a 2 s .c om if (url != null) { eAttachment.setAttribute("url", url); } eAttachment.setAttribute("content-length", "" + data.length); eAttachment.setAttribute("status", status.name()); if (status == Status.timeout) { policy = Policy.base64; } else if (policy == null) { policy = Policy.localfile_increment; } switch (policy) { case base64: eAttachment.setAttribute("encoding", "base64"); eAttachment.appendChild( transaction.context.outputDocument.createTextNode(Base64.encodeBase64String(data))); break; case localfile_override: case localfile_increment: default: if (filename == null || filename.length() == 0) { filename = ".//downloads/" + name; } String projectName = transaction.getProject().getName(); filename = Engine.theApp.filePropertyManager.getFilepathFromProperty(filename, projectName); File file = new File(filename); file.getParentFile().mkdirs(); if (policy == Policy.localfile_increment && file.exists()) { int cpt = 2; String leaf = file.getName(); while ((file = new File(file.getParentFile(), cpt + "_" + leaf)).exists()) { cpt++; } } synchronized (Engine.theApp.filePropertyManager.getMutex(file)) { try { FileOutputStream fileOut = new FileOutputStream(file); fileOut.write(data); fileOut.close(); } catch (IOException e) { Engine.logEngine.error("AttachmentComponent: cannot write attachment '" + name + "'", e); } finally { Engine.theApp.filePropertyManager.releaseMutex(file); } } String filepath = file.getAbsolutePath(); eAttachment.setAttribute("local-url", filepath); String projectPath = Engine.PROJECTS_PATH + File.separator + projectName + File.separator; if (filepath.startsWith(projectPath)) { eAttachment.setAttribute("relative-url", filepath.substring(projectPath.length()).replaceAll("\\\\", "/")); } break; } transaction.context.outputDocument.getDocumentElement().appendChild(eAttachment); }
From source file:com.weaforce.system.component.fckeditor.response.XmlResponse.java
/** * Lists all files in the given dir as XML tags. * /*from w ww. j av a 2 s . c o m*/ * @param dir */ public void setFiles(File dir) { if (filesElement != null) { Element parent = (Element) filesElement.getParentNode(); parent.removeChild(filesElement); } filesElement = document.createElement("Files"); document.getDocumentElement().appendChild(filesElement); File[] fileList = dir.listFiles((FileFilter) FileFileFilter.FILE); long length; for (File file : fileList) { Element fileElement = document.createElement("File"); fileElement.setAttribute("name", file.getName()); if (file.length() < 1024) length = 1L; else length = file.length() / 1024; fileElement.setAttribute("size", String.valueOf(length)); filesElement.appendChild(fileElement); } }
From source file:com.photon.phresco.framework.impl.ConfigurationWriter.java
/** * creates the environment/* w ww .ja va 2 s.com*/ * @param selectedEnvs */ public void createEnvironment(List<Environment> envs) { for (Environment env : envs) { Element envNode = getDocument().createElement("environment"); envNode.setAttribute("name", env.getName()); envNode.setAttribute("desc", env.getDesc()); envNode.setAttribute("default", Boolean.toString(env.isDefaultEnv())); getRootElement().appendChild(envNode); } }
From source file:no.dusken.barweb.view.InvoiceView.java
private Document generateXml(Map<BarPerson, Integer> persons, Gjeng gjeng, Invoice invoice) { Document dom = null;/*w w w .j a v a 2 s. c o m*/ //get an instance of factory DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); try { //get an instance of builder DocumentBuilder db = dbf.newDocumentBuilder(); //create an instance of DOM dom = db.newDocument(); } catch (ParserConfigurationException pce) { log.error("Error when generating invoice"); } Element root = createInvoiceElement(invoice, gjeng, dom); SimpleDateFormat dateformat = new SimpleDateFormat("dd. MMMMMMMMM yyyy - HH:mm", new Locale("no")); root.setAttribute("generated", dateformat.format((new GregorianCalendar()).getTime())); root.setAttribute("magicNumber", String.valueOf(((new Random()).nextDouble() * 1000))); dom.appendChild(root); Element personsEle = dom.createElement("persons"); for (Map.Entry<BarPerson, Integer> p : persons.entrySet()) { Element personEle = createPersonElement(p.getKey(), p.getValue(), dom); personsEle.appendChild(personEle); } root.appendChild(personsEle); return dom; }
From source file:fr.aliasource.webmail.server.proxy.client.http.AbstractMessageMethod.java
private void addRecips(Element recipients, List<EmailAddress> recip) { for (EmailAddress a : recip) { Element p = DOMUtils.createElement(recipients, "r"); p.setAttribute("displayName", a.getDisplay()); String ma = a.getEmail(); p.setAttribute("addr", ma); }//from w ww . j a va 2 s.c o m }
From source file:de.e7o.caldav.caldav.CaldavServer.java
public void prepareRootElement(Element root) { root.setAttribute("xmlns:D", "DAV:"); root.setAttribute("xmlns:CS", "http://calendarserver.org/ns/"); root.setAttribute("xmlns:C", "urn:ietf:params:xml:ns:caldav"); }
From source file:eu.apenet.dpt.standalone.gui.hgcreation.LevelTreeActions.java
private Node createTree(Document doc, TreeModel model, Object node, HashMap<String, String> paramMap) { CLevelTreeObject obj = (CLevelTreeObject) ((DefaultMutableTreeNode) node).getUserObject(); if (obj.isFile()) { File file = obj.getFile(); try {/*w w w . j a v a2s . c o m*/ File outputFileTmp = new File(Utilities.TEMP_DIR + ".temp_HG.xml"); FileWriter fileWriter = new FileWriter(outputFileTmp); InputStream xslIs = TransformationTool.class.getResourceAsStream("/xsl/fa2hg.xsl"); Source xsltSource = new StreamSource(xslIs); StringWriter stringWriter = new StringWriter(); StringWriter xslMessages = TransformationTool.createTransformation( fileUtil.readFileAsInputStream(file), stringWriter, xsltSource, paramMap); fileWriter.write(stringWriter.toString()); fileWriter.close(); List<String> filesWithoutEadid = new ArrayList<String>(); if (xslMessages != null && xslMessages.toString().contains("NO_EADID_IN_FILE")) { filesWithoutEadid.add(file.getName()); } else { Reader reader = new FileReader(outputFileTmp); ReaderInputStream readerInputStream = new ReaderInputStream(reader, "UTF-8"); Node fileLevel = stringToNode(doc, readerInputStream); return fileLevel; // el.getParentNode().appendChild(fileLevel); } outputFileTmp.delete(); } catch (Exception e) { LOG.error("Could not create HG part for file: " + file.getName(), e); // createErrorOrWarningPanel(e, true, "Could not create HG"); } } else { Element el = doc.createElement("c"); Element did = doc.createElement("did"); if (!obj.getId().equals("")) { Element unitid = doc.createElement("unitid"); unitid.setAttribute("encodinganalog", "3.1.1"); unitid.setTextContent(obj.getId()); did.appendChild(unitid); } Element title = doc.createElement("unittitle"); title.setAttribute("encodinganalog", "3.1.2"); title.setTextContent(obj.getName()); did.appendChild(title); el.appendChild(did); if (!obj.getDescription().equals("")) { Element scopecontent = doc.createElement("scopecontent"); scopecontent.setAttribute("encodinganalog", "summary"); Element pElt = doc.createElement("p"); pElt.setTextContent(obj.getDescription()); scopecontent.appendChild(pElt); el.appendChild(scopecontent); } for (int i = 0; i < model.getChildCount(node); i++) { Object child = model.getChild(node, i); el.appendChild(createTree(doc, model, child, paramMap)); } return el; } return null; }
From source file:com.photon.phresco.framework.impl.ConfigurationWriter.java
private Element createConfigElement(SettingsInfo settingsInfo) { Element configNode = getDocument().createElement(settingsInfo.getType()); configNode.setAttribute("name", settingsInfo.getName()); configNode.setAttribute("desc", settingsInfo.getDescription()); List<String> appliesTo = settingsInfo.getAppliesTo(); if (CollectionUtils.isNotEmpty(appliesTo)) { String appliesToAsStr = getAppliesToAsStr(appliesTo); configNode.setAttribute("appliesTo", appliesToAsStr); }/*from ww w . ja v a 2 s.c o m*/ createProperties(configNode, settingsInfo.getPropertyInfos()); return configNode; }