List of usage examples for org.w3c.dom Element setTextContent
public void setTextContent(String textContent) throws DOMException;
From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureFacet.java
private void addSignatureInfo(XMLSignatureFactory signatureFactory, Document document, String signatureId, List<Reference> references, List<XMLObject> objects) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { List<XMLStructure> objectContent = new LinkedList<XMLStructure>(); Element signatureInfoElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureInfoV1"); signatureInfoElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns", OFFICE_DIGSIG_NS); Element setupIDElement = document.createElementNS(OFFICE_DIGSIG_NS, "SetupID"); signatureInfoElement.appendChild(setupIDElement); Element signatureTextElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureText"); signatureInfoElement.appendChild(signatureTextElement); Element signatureImageElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureImage"); signatureInfoElement.appendChild(signatureImageElement); Element signatureCommentsElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureComments"); signatureInfoElement.appendChild(signatureCommentsElement); Element windowsVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "WindowsVersion"); windowsVersionElement.setTextContent("6.1"); signatureInfoElement.appendChild(windowsVersionElement); Element officeVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "OfficeVersion"); officeVersionElement.setTextContent("15.0"); signatureInfoElement.appendChild(officeVersionElement); Element applicationVersionElement = document.createElementNS(OFFICE_DIGSIG_NS, "ApplicationVersion"); applicationVersionElement.setTextContent("15.0"); signatureInfoElement.appendChild(applicationVersionElement); Element monitorsElement = document.createElementNS(OFFICE_DIGSIG_NS, "Monitors"); monitorsElement.setTextContent("1"); signatureInfoElement.appendChild(monitorsElement); Element horizontalResolutionElement = document.createElementNS(OFFICE_DIGSIG_NS, "HorizontalResolution"); horizontalResolutionElement.setTextContent("1366"); signatureInfoElement.appendChild(horizontalResolutionElement); Element verticalResolutionElement = document.createElementNS(OFFICE_DIGSIG_NS, "VerticalResolution"); verticalResolutionElement.setTextContent("768"); signatureInfoElement.appendChild(verticalResolutionElement); Element colorDepthElement = document.createElementNS(OFFICE_DIGSIG_NS, "ColorDepth"); colorDepthElement.setTextContent("32"); signatureInfoElement.appendChild(colorDepthElement); Element signatureProviderIdElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureProviderId"); signatureProviderIdElement.setTextContent("{00000000-0000-0000-0000-000000000000}"); signatureInfoElement.appendChild(signatureProviderIdElement); Element signatureProviderUrlElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureProviderUrl"); signatureInfoElement.appendChild(signatureProviderUrlElement); Element signatureProviderDetailsElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureProviderDetails"); signatureProviderDetailsElement.setTextContent("9"); signatureInfoElement.appendChild(signatureProviderDetailsElement); Element manifestHashAlgorithmElement = document.createElementNS(OFFICE_DIGSIG_NS, "ManifestHashAlgorithm"); manifestHashAlgorithmElement.setTextContent("http://www.w3.org/2000/09/xmldsig#sha1"); signatureInfoElement.appendChild(manifestHashAlgorithmElement); Element signatureTypeElement = document.createElementNS(OFFICE_DIGSIG_NS, "SignatureType"); signatureTypeElement.setTextContent("1"); signatureInfoElement.appendChild(signatureTypeElement); List<XMLStructure> signatureInfoContent = new LinkedList<XMLStructure>(); signatureInfoContent.add(new DOMStructure(signatureInfoElement)); SignatureProperty signatureInfoSignatureProperty = signatureFactory .newSignatureProperty(signatureInfoContent, "#" + signatureId, "idOfficeV1Details"); List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>(); signaturePropertyContent.add(signatureInfoSignatureProperty); SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent, null);/*from w w w . java 2 s . com*/ objectContent.add(signatureProperties); String objectId = "idOfficeObject"; objects.add(signatureFactory.newXMLObject(objectContent, objectId, null, null)); DigestMethod digestMethod = signatureFactory.newDigestMethod(this.digestAlgo.getXmlAlgoId(), null); Reference reference = signatureFactory.newReference("#" + objectId, digestMethod, null, "http://www.w3.org/2000/09/xmldsig#Object", null); references.add(reference); }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public Element setVet(String sName, String sLicNo, String sNAN, String sPhone) { if (!isValidDoc()) return null; Element eVet = null;//from w ww. j av a 2 s .c o m if (sName != null && sName.trim().length() > 0) { eVet = childElementByName(root, "Veterinarian"); if (eVet == null) { eVet = doc.createElement("Veterinarian"); Element after = childElementByNames(root, "MovementPurpose,Origin,Destination,Consignor,Consignee,Accessions,Animal,GroupLot,Attachment"); if (after != null) root.insertBefore(eVet, after); else root.appendChild(eVet); } if (sLicNo != null && sLicNo.trim().length() > 0) eVet.setAttribute("LicenseNumber", sLicNo); if (sNAN != null && sNAN.trim().length() > 0) eVet.setAttribute("NationalAccreditationNumber", sNAN); Element person = childElementByName(eVet, "Person"); if (person == null) { person = doc.createElement("Person"); eVet.appendChild(person); } Element name = childElementByName(person, "Name"); if (name == null) { name = doc.createElement("Name"); person.appendChild(name); } name.setTextContent(sName); if (sPhone != null && sPhone.trim().length() > 0) { Element phone = childElementByName(person, "Phone"); if (phone == null) { phone = doc.createElement("Phone"); person.appendChild(phone); } phone.setAttribute("Type", "Unknown"); phone.setAttribute("Number", sPhone); } } return eVet; }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public void setPurpose(String sPurpose) { if (isValidDoc() && sPurpose != null && sPurpose.trim().length() > 0) { Element purposes = childElementByName(root, "MovementPurposes"); if (purposes == null) { purposes = doc.createElement("MovementPurposes"); Node after = childNodeByNames(root, "Origin,Destination,Consignor,Consignee,Accessions,Animal,GroupLot,Attachment"); root.insertBefore(purposes, after); }//ww w . j a v a2 s . c om Element purpose = childElementByName(purposes, "MovementPurpose"); if (purpose == null) { purpose = doc.createElement("MovementPurpose"); purposes.appendChild(purpose); } purpose.setTextContent(sPurpose.toLowerCase()); } }
From source file:com.hin.hl7messaging.InvoiceSvgService.java
public Element createTestTitleElement(Document document, Element subG, String content, String x, String y, String style) {//from w w w. j a v a2 s .co m Element text = document.createElement("text"); text.setAttribute("x", "223.8"); text.setAttribute("y", "781.76"); text.setAttribute("id", "legendTitle"); Element tspan = document.createElement("tspan"); tspan.setAttribute("id", "optimumTitle"); tspan.setAttribute("x", x); tspan.setAttribute("y", y); tspan.setAttribute("style", style); tspan.setTextContent(content); text.appendChild(tspan); subG.appendChild(text); return subG; }
From source file:com.mirth.connect.model.util.ImportConverter.java
private static Element createDefaultValueElement(Document document) { Element entryElement = document.createElement("entry"); Element defaultValueElement = document.createElement("string"); Element defaultValueValueElement = document.createElement("string"); defaultValueElement.setTextContent("DefaultValue"); entryElement.appendChild(defaultValueElement); entryElement.appendChild(defaultValueValueElement); return entryElement; }
From source file:com.bluexml.xforms.controller.mapping.MappingToolAlfrescoToClassForms.java
/** * Fill x forms element non inline./* ww w .j a v a 2s. c o m*/ * * @param xformsDocument * the xforms document * @param targetClassType * the target class type * @param id * the id * @param label * the label * @param targetTypeStr * * @return the node */ private Node fillXFormsElementNonInline(Document xformsDocument, String targetClassType, String id, String label, String targetTypeStr) { Element subNode; subNode = xformsDocument.createElement(MsgId.INT_INSTANCE_ASSOCIATION_ITEM.getText()); subNode.setAttribute("type", targetClassType); // #1665 Element eltLabel = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDELABEL.getText()); eltLabel.setTextContent(StringUtils.trimToEmpty(label)); subNode.appendChild(eltLabel); Element eltId = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDEID.getText()); eltId.setTextContent(id); subNode.appendChild(eltId); Element eltEdit = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDEEDIT.getText()); eltEdit.setTextContent(""); subNode.appendChild(eltEdit); // ** #1485 Element eltType = xformsDocument.createElement(MsgId.INT_INSTANCE_SIDETYPE.getText()); eltType.setTextContent(targetTypeStr); subNode.appendChild(eltType); // ** #1485 return subNode; }
From source file:com.github.sardine.impl.SardineImpl.java
/** * Creates a {@link com.github.sardine.model.Propertyupdate} element containing all properties to set from setProps and all properties to * remove from removeProps. Note this method will use a {@link com.github.sardine.util.SardineUtil#CUSTOM_NAMESPACE_URI} as * namespace and {@link com.github.sardine.util.SardineUtil#CUSTOM_NAMESPACE_PREFIX} as prefix. */// ww w.j a va 2 s .co m @Override public List<DavResource> patch(String url, Map<QName, String> setProps, List<QName> removeProps) throws IOException { HttpPropPatch entity = new HttpPropPatch(url); // Build WebDAV <code>PROPPATCH</code> entity. Propertyupdate body = new Propertyupdate(); // Add properties { Set set = new Set(); body.getRemoveOrSet().add(set); Prop prop = new Prop(); // Returns a reference to the live list List<Element> any = prop.getAny(); for (Map.Entry<QName, String> entry : setProps.entrySet()) { Element element = SardineUtil.createElement(entry.getKey()); element.setTextContent(entry.getValue()); any.add(element); } set.setProp(prop); } // Remove properties { Remove remove = new Remove(); body.getRemoveOrSet().add(remove); Prop prop = new Prop(); // Returns a reference to the live list List<Element> any = prop.getAny(); for (QName entry : removeProps) { Element element = SardineUtil.createElement(entry); any.add(element); } remove.setProp(prop); } entity.setEntity(new StringEntity(SardineUtil.toXml(body), UTF_8)); Multistatus multistatus = this.execute(entity, new MultiStatusResponseHandler()); List<Response> responses = multistatus.getResponse(); List<DavResource> resources = new ArrayList<DavResource>(responses.size()); for (Response response : responses) { try { resources.add(new DavResource(response)); } catch (URISyntaxException e) { log.warn(String.format("Ignore resource with invalid URI %s", response.getHref().get(0))); } } return resources; }
From source file:com.mirth.connect.model.util.ImportConverter.java
/** * Update the child property elements of a properties element * //from w ww .j a v a2 s.c o m * @param document * The document to use to generate new Elements. * @param properties * The properties element to be modified. * @param defaultProperties * Properties to be added only if they are missing. * @param changeProperties * Properties to be added if missing, or changed if already * present. */ private static void updateProperties(Document document, Element properties, Map<String, String> defaultProperties, Map<String, String> changeProperties) throws Exception { // Make a working copy of the properies so we can remove existing // properties Map<String, String> missingProperties = new HashMap<String, String>(); missingProperties.putAll(defaultProperties); missingProperties.putAll(changeProperties); // Removes all existing properties from the working copy, and changes // the value of any // change properties NodeList existingProperties = properties.getElementsByTagName("property"); for (int i = 0; i < existingProperties.getLength(); i++) { Node existingProperty = existingProperties.item(i); Node existingPropertyNameAttribute = existingProperty.getAttributes().getNamedItem("name"); String existingPropertyName = existingPropertyNameAttribute.getNodeValue(); if (missingProperties.containsKey(existingPropertyName)) { if (changeProperties.containsKey(existingPropertyName)) { existingProperty.setTextContent(changeProperties.get(existingPropertyName)); } missingProperties.remove(existingPropertyName); } } // And any remaining default or change properties for (Map.Entry<String, String> thisEntry : missingProperties.entrySet()) { Element newProperty = document.createElement("property"); newProperty.setAttribute("name", thisEntry.getKey()); newProperty.setTextContent(thisEntry.getValue()); properties.appendChild(newProperty); } }
From source file:eu.europa.esig.dss.xades.signature.XAdESSignatureBuilder.java
/** * Adds the content of a timestamp into a given timestamp element * * @param timestampElement// ww w.j a v a2 s . c om */ protected void addTimestamp(final Element timestampElement, final TimestampToken token) { //List<TimestampInclude> includes, String canonicalizationMethod, TimestampToken encapsulatedTimestamp) { //add includes: URI + referencedData = "true" //add canonicalizationMethod: Algorithm //add encapsulatedTimestamp: Encoding, Id, while its textContent is the base64 encoding of the data to digest final List<TimestampInclude> includes = token.getTimestampIncludes(); if (includes != null) { for (final TimestampInclude include : includes) { final Element timestampIncludeElement = documentDom.createElementNS(XAdES, XADES_INCLUDE); timestampIncludeElement.setAttribute(URI, "#" + include.getURI()); timestampIncludeElement.setAttribute(REFERENCED_DATA, "true"); timestampElement.appendChild(timestampIncludeElement); } } final Element canonicalizationMethodElement = documentDom.createElementNS(XMLNS, DS_CANONICALIZATION_METHOD); canonicalizationMethodElement.setAttribute(ALGORITHM, token.getCanonicalizationMethod()); timestampElement.appendChild(canonicalizationMethodElement); Element encapsulatedTimestampElement = documentDom.createElementNS(XAdES, XADES_ENCAPSULATED_TIME_STAMP); encapsulatedTimestampElement.setTextContent(Base64.encodeBase64String(token.getEncoded())); timestampElement.appendChild(encapsulatedTimestampElement); }
From source file:com.ggvaidya.scinames.model.Project.java
public void serializeToDocument(Document doc) { // Add top-level element. Element project = doc.createElement("project"); project.setAttribute("name", getName()); doc.appendChild(project);//from w ww . j a v a 2 s. com // Set up some properties. properties.put(PROP_NAME_EXTRACTORS, getNameExtractors().stream().map(lne -> NameExtractorFactory.serializeExtractorsToString(lne)) .distinct().sorted().collect(Collectors.joining("; "))); // Write out properties. Element propertiesElement = doc.createElement("properties"); for (String key : properties.keySet()) { Element p = doc.createElement("property"); p.setAttribute("name", key); p.setTextContent(properties.get(key)); propertiesElement.appendChild(p); } project.appendChild(propertiesElement); // Add filters. Element filtersElement = doc.createElement("filters"); Deque<ChangeFilter> changeFilters = new LinkedList<>(); { // We need to read the filters inside-out, so they'll be recreated // the right way around. ChangeFilter cf = getChangeFilter(); while (cf != null) { changeFilters.addLast(cf); cf = cf.getPrevChangeFilter(); } } changeFilters.forEach(cf -> { // Skip any nulls. if (cf.getShortName().equals("null")) return; filtersElement.appendChild(cf.serializeToElement(doc)); }); project.appendChild(filtersElement); // List all timepoints. Element timepointsElement = doc.createElement("datasets"); for (Dataset tp : getDatasets()) { Element t = tp.serializeToElement(doc); timepointsElement.appendChild(t); } project.appendChild(timepointsElement); }