List of usage examples for org.w3c.dom Element setAttribute
public void setAttribute(String name, String value) throws DOMException;
From source file:Main.java
/** * /* w w w . ja v a2 s .c o m*/ */ public static Document createVmlDocument() { Document document = createDocument(); Element root = document.createElement("html"); root.setAttribute("xmlns:v", "urn:schemas-microsoft-com:vml"); root.setAttribute("xmlns:o", "urn:schemas-microsoft-com:office:office"); document.appendChild(root); Element head = document.createElement("head"); Element style = document.createElement("style"); style.setAttribute("type", "text/css"); style.appendChild(document.createTextNode("<!-- v\\:* {behavior: url(#default#VML);} -->")); head.appendChild(style); root.appendChild(head); Element body = document.createElement("body"); root.appendChild(body); return document; }
From source file:Main.java
protected static void setAttribute(Element element, String attribute, String attributeValue, String attributeDefaultValue) { element.setAttribute(attribute, attributeValue == null ? attributeDefaultValue : attributeValue); }
From source file:Utils.java
public static Element createNewElementAndSetAndAttribute(Document document, Element parent, String childElement, String childValue, String attributeName, String attributeValue) { Element child = createNewElementAndSet(document, parent, childElement, childValue); child.setAttribute(attributeName, attributeValue); return child; }
From source file:Main.java
public static void writeAttribute(Document document, String[] path, String name, String value) { Element element = getElement(document, path, null); element.setAttribute(name, value); }
From source file:Main.java
public static Document parseMetadataMap(Map<String, String> metainfo) throws Exception { DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); DocumentBuilder bd = fact.newDocumentBuilder(); Document doc = bd.newDocument(); Element rt = doc.createElement("ROOT"); doc.appendChild(rt);/* w ww. java 2s.co m*/ for (String key : metainfo.keySet()) { Element e1 = doc.createElement("param"); e1.setAttribute("key", key); String value = metainfo.get(key); e1.setAttribute("value", value); rt.appendChild(e1); } return doc; }
From source file:Main.java
public static void appendCollection(Node node, Object[] o, String tag) { Element child = node.getOwnerDocument().createElement(tag); for (int i = 0; i < o.length; i++) { child.setAttribute("element_" + i, (String) o[i]); }/* w w w .ja va 2s . c o m*/ node.appendChild(child); }
From source file:Main.java
public static void setIntegerAttr(Element element, String name, Integer val) { if (val != null) { element.setAttribute(name, val.toString()); }//from w w w. j ava 2 s .c o m }
From source file:Main.java
/** * Sets an attribute on the specified element with the specified name if the specified * value is different from the specified default value. * * @param base/*from w ww. j a v a 2 s . c o m*/ * the Element to set the attribute on * @param name * the attribute name * @param value * the value that attribute should be set to * @param defaultValue * the default value of the attribute */ public static void attributeBooleanSet(Element base, String name, boolean value, boolean defaultValue) { if (value != defaultValue) { base.setAttribute(name, Boolean.toString(value)); } }
From source file:Main.java
/** * Creates a new {@link Document}.//from w w w. j av a2 s.c o m * * @param rootElementName The name of the root element. * @param xmlns The namespace of the document. * @return Returns said {@link Document}. */ public static Document createDocument(String rootElementName, String xmlns) { final Document doc = createDocument(); final Element root = doc.createElement(rootElementName); if (xmlns != null) root.setAttribute("xmlns", xmlns); doc.appendChild(root); return doc; }
From source file:Main.java
/** * Add the service references to the document. * * @param document// w ww .j a v a2 s . co m */ // FIXME: This provides trivial information. Necessary? public static void addServices(Document document) { if (document != null) { Element root = document.getDocumentElement(); if (root != null) { Element element = document.createElement("services"); Element service = document.createElement("service"); service.setAttribute("name", "run"); service.setAttribute("url", "run"); element.appendChild(service); service = document.createElement("service"); service.setAttribute("name", "module"); service.setAttribute("url", "module"); element.appendChild(service); root.appendChild(element); } } }