List of usage examples for org.w3c.dom Element setAttribute
public void setAttribute(String name, String value) throws DOMException;
From source file:bpsperf.modelgen.BPMNGenerator.java
public void generateXORServiceTasks(int numGateways, String serviceClass) throws Exception { Element start = addNode(startEvent, "startEvent"); Element end = addNode(endEvent, "endEvent"); Element xorS = null;//from w w w . j a v a 2 s . c o m for (int i = 1; i <= numGateways; i++) { Element xor = addNode(xorGateway, "xor" + i); Element task = addNode(serviceTask, "st" + i); task.setAttributeNS(activitins, "class", serviceClass); Element defaultFlow = connect(xor, task); xor.setAttribute("default", defaultFlow.getAttribute("id")); connect(task, end); if (xorS == null) { connect(start, xor); } else { Element conFlow = connect(xorS, xor); Element condition = addElement(conFlow, ns, "conditionExpression"); condition.setAttributeNS(xsins, "type", "tFormalExpression"); CDATASection expression = doc.createCDATASection("${v1 >= " + i + "}"); condition.appendChild(expression); } xorS = xor; } Element conditionTask = addNode(serviceTask, "st_condition"); conditionTask.setAttributeNS(activitins, "class", serviceClass); Element lastConFlow = connect(xorS, conditionTask); Element condition = addElement(lastConFlow, ns, "conditionExpression"); condition.setAttributeNS(xsins, "type", "tFormalExpression"); CDATASection expression = doc.createCDATASection("${v1 > 10000}"); condition.appendChild(expression); connect(conditionTask, end); }
From source file:com.liferay.portal.editor.fckeditor.receiver.impl.BaseCommandReceiver.java
private Node _createRoot(Document document, String command, String resourceType, String path, String url) { Element rootElement = document.createElement("Connector"); document.appendChild(rootElement);//from w w w . j ava 2 s . c o m rootElement.setAttribute("command", command); rootElement.setAttribute("resourceType", resourceType); Element currentFolderElement = document.createElement("CurrentFolder"); rootElement.appendChild(currentFolderElement); currentFolderElement.setAttribute("path", path); currentFolderElement.setAttribute("url", url); return rootElement; }
From source file:cz.incad.kramerius.service.replication.ExternalReferencesFormat.java
private void changeDatastreamVersion(Document document, Element datastream, Element version, URL url) throws IOException { InputStream is = null;/* w w w . j a va 2 s. co m*/ try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); URLConnection urlConnection = url.openConnection(); is = urlConnection.getInputStream(); IOUtils.copyStreams(is, bos); version.setAttribute("SIZE", "" + bos.size()); version.removeChild(XMLUtils.findElement(version, "contentLocation", version.getNamespaceURI())); Element binaryContent = document.createElementNS(version.getNamespaceURI(), "binaryContent"); document.adoptNode(binaryContent); binaryContent.setTextContent(new String(Base64.encodeBase64(bos.toByteArray()))); version.appendChild(binaryContent); datastream.setAttribute("CONTROL_GROUP", "M"); } finally { IOUtils.tryClose(is); } }
From source file:edu.lternet.pasta.datapackagemanager.LevelOneEMLFactory.java
private void setSystemAttribute(Document levelZeroEMLDocument) { Element rootElement = levelZeroEMLDocument.getDocumentElement(); rootElement.setAttribute("system", LEVEL_ONE_SYSTEM_ATTRIBUTE); }
From source file:be.fedict.eid.applet.service.signer.ooxml.RelationshipTransformService.java
@Override public void marshalParams(XMLStructure parent, XMLCryptoContext context) throws MarshalException { LOG.debug("marshallParams(parent,context)"); DOMStructure domParent = (DOMStructure) parent; Node parentNode = domParent.getNode(); Element parentElement = (Element) parentNode; parentElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi", "http://schemas.openxmlformats.org/package/2006/digital-signature"); Document document = parentNode.getOwnerDocument(); for (String sourceId : this.sourceIds) { Element relationshipReferenceElement = document.createElementNS( "http://schemas.openxmlformats.org/package/2006/digital-signature", "mdssi:RelationshipReference"); relationshipReferenceElement.setAttribute("SourceId", sourceId); parentElement.appendChild(relationshipReferenceElement); }/*from w w w . j ava 2s.c o m*/ for (String sourceType : this.sourceTypes) { Element relationshipsGroupReferenceElement = document.createElementNS( "http://schemas.openxmlformats.org/package/2006/digital-signature", "mdssi:RelationshipsGroupReference"); relationshipsGroupReferenceElement.setAttribute("SourceType", sourceType); parentElement.appendChild(relationshipsGroupReferenceElement); } }
From source file:com.microsoft.tfs.core.clients.versioncontrol.internal.localworkspace.LocalItemExclusionCache.java
/** * Save the exclusion data under the specified node in the specified * document. We don't clear the dirty flag here because the caller could * fail to write the data to disk. The caller should clear the dirty flag * once the save has been successful. See Load for some sample XML. *//*from w w w . j a va 2 s. c o m*/ private void save(final LocalItemExclusionCache cacheOnDisk, final Element rootElement) { // If there is an existing cache file, merge the current cache and the // cache file. if (cacheOnDisk != null) { merge(cacheOnDisk); } for (final InternalServerInfo key : exclusions.keySet()) { final ExclusionSet value = exclusions.get(key); final Element tpcElement = DOMUtils.appendChild(rootElement, TEAM_PROJECT_COLLECTION); tpcElement.setAttribute(COLLECTION_ID, key.getServerGUID().getGUIDString()); tpcElement.setAttribute(COLLECTION_URL, key.getURI().toString()); value.save(tpcElement); } }
From source file:fr.aliasource.webmail.proxy.impl.ResponderImpl.java
public void sendMessages(ConversationReference cr, MailMessage[] ms) { try {/*from ww w . ja va 2s . c om*/ Document doc = DOMUtils.createDoc("http://obm.aliasource.fr/xsd/messages", "messages"); Element root = doc.getDocumentElement(); if (cr != null) { DOMUtils.createElementAndText(root, "title", cr.getTitle()); root.setAttribute("read", "" + cr.isRead()); } for (int i = 0; i < ms.length; i++) { appendMessage(root, "m", ms[i]); } sendDom(doc); } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:com.icesoft.faces.renderkit.dom_html_basic.FormRenderer.java
public void encodeBegin(FacesContext facesContext, UIComponent uiComponent) throws IOException { validateParameters(facesContext, uiComponent, UIForm.class); validateNestingForm(uiComponent);/*ww w . j a v a2s. c o m*/ DOMContext domContext = DOMContext.attachDOMContext(facesContext, uiComponent); String formClientId = uiComponent.getClientId(facesContext); if (!domContext.isInitialized()) { Element root = domContext.createElement("form"); domContext.setRootNode(root); root.setAttribute("id", formClientId); root.setAttribute("method", "post"); root.setAttribute("action", "javascript:;"); String styleClass = (String) uiComponent.getAttributes().get("styleClass"); if (styleClass != null) { root.setAttribute("class", styleClass); } String acceptcharset = (String) uiComponent.getAttributes().get("acceptcharset"); if (acceptcharset != null) { root.setAttribute("accept-charset", acceptcharset); } //redirect form submits String redirectScript = "$element(document.getElementById('" + formClientId + "')).captureAndRedirectSubmit();"; Element scriptElement = (Element) root.appendChild(domContext.createElement("script")); scriptElement.setAttribute("type", "text/javascript"); scriptElement.setAttribute("id", ClientIdPool.get(formClientId + "script")); scriptElement.appendChild(domContext.createTextNode(redirectScript)); root.appendChild(scriptElement); // this hidden field will be checked in the decode method to // determine if this form has been submitted. Element formHiddenField = domContext.createElement("input"); formHiddenField.setAttribute("type", "hidden"); formHiddenField.setAttribute("name", formClientId); formHiddenField.setAttribute("value", formClientId); root.appendChild(formHiddenField); // Only render the css update field once. Rendering more then one will cause // a duplicate ID error Element cssUpdateField = domContext.createElement(HTML.INPUT_ELEM); cssUpdateField.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN); cssUpdateField.setAttribute(HTML.NAME_ATTR, CurrentStyle.CSS_UPDATE_FIELD); cssUpdateField.setAttribute(HTML.VALUE_ATTR, ""); root.appendChild(cssUpdateField); } // This has to occur outside the isInitialized test, as it has to happen // all the time, even if the form otherwise has not changed. Element root = (Element) domContext.getRootNode(); String conversationId = SeamUtilities.getSeamConversationId(); if (conversationId != null) { String conversationParamName = SeamUtilities.getConversationIdParameterName(); Element conversationIDElement = domContext.createElement(HTML.INPUT_ELEM); if (log.isDebugEnabled()) { log.debug("Embedding Seam Param - name: " + conversationParamName + ", value: " + conversationId); } conversationIDElement.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN); conversationIDElement.setAttribute(HTML.NAME_ATTR, conversationParamName); conversationIDElement.setAttribute(HTML.VALUE_ATTR, conversationId); // # 4581 put id into hidden field for dom diffing. conversationIDElement.setAttribute(HTML.ID_ATTR, "cid:" + formClientId); root.appendChild(conversationIDElement); } String flowId = SeamUtilities.getSpringFlowId(); if (flowId != null) { String flowParamName = SeamUtilities.getFlowIdParameterName(); Element flowIDElement = domContext.createElement(HTML.INPUT_ELEM); if (log.isDebugEnabled()) { log.debug("Embedding Spring Param - name: " + flowParamName + ", value: " + flowId); } String flowParamId = formClientId + ":" + flowParamName; flowIDElement.setAttribute(HTML.TYPE_ATTR, HTML.INPUT_TYPE_HIDDEN); flowIDElement.setAttribute(HTML.NAME_ATTR, flowParamName); flowIDElement.setAttribute(HTML.ID_ATTR, flowParamId); flowIDElement.setAttribute(HTML.VALUE_ATTR, flowId); root.appendChild(flowIDElement); } //String contextClass = facesContext.getClass().toString(); //root.setAttribute("context_type", contextClass); PassThruAttributeRenderer.renderHtmlAttributes(facesContext, uiComponent, passThruAttributes); String autoComplete = (String) uiComponent.getAttributes().get(HTML.AUTOCOMPLETE_ATTR); if (autoComplete != null && "off".equalsIgnoreCase(autoComplete)) { root.setAttribute(HTML.AUTOCOMPLETE_ATTR, "off"); } // don't override user-defined value String userDefinedValue = root.getAttribute("onsubmit"); if (userDefinedValue == null || userDefinedValue.equalsIgnoreCase("")) { root.setAttribute("onsubmit", "return false;"); } facesContext.getApplication().getViewHandler().writeState(facesContext); // Currently we have to put the marker node in the DOM here, because // the DOMResponseWriter doesn't have the same View of the DOM as this object does, // because this object isn't using the DOMResponseWriter. ResponseWriter writer = facesContext.getResponseWriter(); if (ImplementationUtil.isJSFStateSaving() && (writer instanceof DOMResponseWriter)) { DOMResponseWriter domWriter = (DOMResponseWriter) writer; Node n = domContext.createElement("div"); String id = formClientId + NamingContainer.SEPARATOR_CHAR + STATE_SAVING_MARKER; root.appendChild(n); ((Element) n).setAttribute("id", id); ((Element) n).setAttribute(HTML.STYLE_ATTR, "width:0px;height:0px;"); domWriter.trackMarkerNode(n); } domContext.stepInto(uiComponent); }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.io.SdocBuilder.java
private void createMetaDataElement(final Element parent, final String key) { if (Constant.isIntendedForMiscSection(key)) { final Element metadata = createContentElement("metadata", key, parent); if (metadata != null) { metadata.setAttribute(GI_NAME, key); }/*from w w w . ja v a 2 s . c om*/ } }