List of usage examples for org.w3c.dom Element setAttribute
public void setAttribute(String name, String value) throws DOMException;
From source file:com.minhthuong.pfi.controller.PFIViewController.java
private void addHeaders(RenderRequest request, RenderResponse response) { log.log(Level.INFO, "show.edit.START"); Element cssElement = response.createElement("link"); cssElement.setAttribute("rel", "stylesheet"); cssElement.setAttribute("type", "text/css"); //cssElement.setAttribute("href", //response.encodeURL("http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css")); cssElement.setAttribute("href", response.encodeURL(request.getContextPath() + "/bootstrap/bootstrap.css")); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, cssElement); cssElement = response.createElement("link"); cssElement.setAttribute("rel", "stylesheet"); cssElement.setAttribute("type", "text/css"); cssElement.setAttribute("href", response.encodeURL((request.getContextPath() + "/css/list.css"))); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, cssElement); Element jsElement = response.createElement("script"); jsElement.setAttribute("src", response.encodeURL((request.getContextPath() + "/js/jquery.js"))); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jsElement); jsElement = response.createElement("script"); jsElement.setAttribute("src", response.encodeURL((request.getContextPath() + "/js/jquery.dataTables.js"))); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jsElement); jsElement = response.createElement("script"); jsElement.setAttribute("type", "text/javascript"); jsElement.setAttribute("src", response.encodeURL((request.getContextPath() + "/js/list.js"))); response.addProperty(MimeResponse.MARKUP_HEAD_ELEMENT, jsElement); }
From source file:com.springsource.hq.plugin.tcserver.plugin.serverconfig.resources.jdbc.DataSourcesConverter.java
public void convert(final Document document, Element server, Set<DataSource> from, Properties catalinaProperties) { final List<Element> globalNamingResourcesList = getChildElements(server, "GlobalNamingResources"); if (globalNamingResourcesList.size() > 1) { throw new InvalidNodeException( "Unable to determine existing DataSources. Found multiple GlobalNamingResource Elements in server.xml"); }//from w w w. j av a 2 s.c o m final Set<String> dataSourceIds = new HashSet<String>(from.size()); for (DataSource dataSource : from) { dataSourceIds.add(dataSource.getId()); } final Map<String, Element> dataSourceElements = new HashMap<String, Element>(); Element globalNamingResources; if (globalNamingResourcesList.isEmpty()) { globalNamingResources = document.createElement("GlobalNamingResources"); server.appendChild(globalNamingResources); } else { globalNamingResources = globalNamingResourcesList.get(0); final List<Element> resources = getChildElements(globalNamingResources, "Resource"); for (int i = 0; i < resources.size(); i++) { Element resource = (Element) resources.get(i); if (DATA_SOURCE_TYPE.equals(resource.getAttribute("type"))) { final String name = parseProperties(resource.getAttribute("name"), catalinaProperties); if (dataSourceIds.contains(name)) { dataSourceElements.put(name, resource); } else if (dataSourceConverter.isDataSourceFactorySupported(resource, catalinaProperties)) { globalNamingResources.removeChild(resource); } } } } for (DataSource dataSource : from) { if (dataSourceElements.get(dataSource.getId()) == null) { final Element dataSourceElement = document.createElement("Resource"); dataSourceElement.setAttribute("type", DATA_SOURCE_TYPE); dataSourceConverter.convert(document, dataSourceElement, dataSource, catalinaProperties); globalNamingResources.appendChild(dataSourceElement); } else { dataSourceConverter.convert(document, dataSourceElements.get(dataSource.getId()), dataSource, catalinaProperties); } } }
From source file:com.microsoft.tfs.core.credentials.internal.CachedCredentialsSerializer.java
/** * {@inheritDoc}/* ww w . j a v a2 s .co m*/ */ @Override protected Document createDocumentFromComponent(final Object object) { @SuppressWarnings("unchecked") final Map<URI, CachedCredentials> credentialsMap = (Map<URI, CachedCredentials>) object; final Document document = DOMCreateUtils.newDocument(CREDENTIALS_CACHE_ELEMENT_NAME); final Element rootElement = document.getDocumentElement(); rootElement.setAttribute(VERSION_ATTRIBUTE_NAME, String.valueOf(SCHEMA_VERSION)); for (final CachedCredentials credentials : credentialsMap.values()) { serializeCredentials(credentials, document, rootElement); } return document; }
From source file:Main.java
/** * Renames the attribute with the new name * /*from w w w . j a va 2s. c om*/ * @param elementObject * the element object * @param oldName * Old name of the attribute * @param newName * New name of the attribute */ public static void renameAttribute(final Element elementObject, final String oldName, final String newName) throws IllegalArgumentException { // Validate element Object if (elementObject == null) { throw new IllegalArgumentException( "Element object cannot be null" + " in XmlUtils.renameAttribute method"); } // Validate old name if (oldName == null) { throw new IllegalArgumentException("Old name cannot be null" + " in XmlUtils.renameAttribute method"); } // Validate new name if (newName == null) { throw new IllegalArgumentException("New name cannot be null" + " in XmlUtils.renameAttribute method"); } // the attribute value String attributeValue = null; // get the value of the attribute attributeValue = getAttribute(elementObject, oldName, null); // remove the old attribute elementObject.removeAttribute(oldName); // if the attribute value is not null then set the attribute if (attributeValue != null) { elementObject.setAttribute(newName, attributeValue); } }
From source file:no.dusken.barweb.view.XListView.java
private Element createPersonElement(BarPerson p, Document dom, Integer lowLimit) { Element personEle = dom.createElement("barPerson"); Boolean enoughMoney = p.getMoney() >= lowLimit; personEle.setAttribute("enoughmoney", enoughMoney.toString()); personEle.setTextContent(p.getName()); return personEle; }
From source file:org.mule.module.activiti.config.ActionChildDefinitionParser.java
protected void parseChild(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { super.parseChild(element, parserContext, builder); Map result = new ManagedMap(); element.setAttribute("class", this.valueClass.getCanonicalName()); element.setAttribute("name", "_activiti_action_" + actionsCount.incrementAndGet()); BeanDefinition definition = new OrphanDefinitionParser(this.valueClass, false).parse(element, parserContext);/*from ww w . ja va 2 s. c o m*/ result.put(this.key, definition); builder.addPropertyValue("sourceMap", result); builder.addPropertyValue("targetMapClass", HashMap.class); }
From source file:be.fedict.eid.applet.service.util.KmlLightDocument.java
/** * Constructor//from w w w.j av a 2 s .c o m * * @throws IOException */ public KmlLightDocument() throws IOException { try { DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = fact.newDocumentBuilder(); docKml = builder.newDocument(); Element elKml = docKml.createElement("kml"); elKml.setAttribute("xmlns", KmlLightDocument.KML_NS); docKml.appendChild(elKml); } catch (Exception e) { throw new IOException(e); } }
From source file:de.pixida.logtest.reporting.XUnitReportGenerator.java
private void addTestCases(final Document doc, final Element rootElement) { for (final Entry<Job, List<Triple<LogSink, EvaluationResult, Long>>> resultSet : this.results.entrySet()) { // The class name usually includes its packet name which is displayed as tree in Jenkins. // This might lead to the following tree hierarchy: "some-log" -> "txt" -> ..results.. // "some-other-log" -> "txt" -> ..results.. // Furthermore, we down't know how the log source is represented as human readable string, so it may always contain // dots, e.g. "127.0.0.1:8082" for stream sources. // For now, replace all dots by a "-", such that the human readable identifier of the log source remains human readable and // all information is preserved. String className = resultSet.getKey().getLogReader().getDisplayName(); className = className.replace('.', '-'); for (final Triple<LogSink, EvaluationResult, Long> result : resultSet.getValue()) { final String testcaseName = result.getLeft().getDisplayName(); final Element testcase = doc.createElement("testcase"); testcase.setAttribute("classname", className); testcase.setAttribute("name", testcaseName); // Actually, set the job time, not the test time (tests run in parallel). The attribute is mandatory. final long msToSec = 1000; testcase.setAttribute("time", String.valueOf((double) result.getRight() / msToSec)); if (!result.getMiddle().isSuccess()) { final Element error = doc.createElement(result.getMiddle().isError() ? "error" : "failure"); assert result.getMiddle().getMessage() != null; error.setAttribute("type", result.getMiddle().getResult().toString()); error.setAttribute("message", result.getMiddle().getMessage()); testcase.appendChild(error); }/*from w w w . java 2 s. co m*/ rootElement.appendChild(testcase); } } }
From source file:com.msopentech.odatajclient.engine.data.ODataBinder.java
private static Element toDOMElement(final ODataProperty prop, final Document doc, final boolean setType) { final Element element; if (prop.hasNullValue()) { // null property handling element = toNullPropertyElement(prop, doc); } else if (prop.hasPrimitiveValue()) { // primitive property handling element = toPrimitivePropertyElement(prop, doc, setType); } else if (prop.hasCollectionValue()) { // collection property handling element = toCollectionPropertyElement(prop, doc, setType); } else {//from ww w . j a v a2s .c o m // complex property handling element = toComplexPropertyElement(prop, doc, setType); } element.setAttribute(ODataConstants.XMLNS_METADATA, ODataConstants.NS_METADATA); element.setAttribute(ODataConstants.XMLNS_DATASERVICES, ODataConstants.NS_DATASERVICES); element.setAttribute(ODataConstants.XMLNS_GML, ODataConstants.NS_GML); element.setAttribute(ODataConstants.XMLNS_GEORSS, ODataConstants.NS_GEORSS); return element; }
From source file:com.bstek.dorado.idesupport.resolver.RobotResolver.java
protected void assembleError(Document document, Element responseElement, Exception error) { String message = error.getMessage(); if (message == null) { message = error.getClass().getSimpleName(); }/* w ww . j a v a 2 s . co m*/ Element messageElement = document.createElement("Message"); messageElement.appendChild(document.createTextNode(message)); responseElement.appendChild(messageElement); Element stackTraceElement = document.createElement("StackTrace"); responseElement.appendChild(stackTraceElement); StackTraceElement[] stackTrace = error.getStackTrace(); for (StackTraceElement ste : stackTrace) { Element element = document.createElement("Element"); element.setAttribute("className", ste.getClassName()); element.setAttribute("methodName", ste.getMethodName()); element.setAttribute("fileName", ste.getFileName()); element.setAttribute("lineNumber", String.valueOf(ste.getLineNumber())); stackTraceElement.appendChild(element); } }