List of usage examples for org.w3c.dom Element setTextContent
public void setTextContent(String textContent) throws DOMException;
From source file:gov.nih.nci.cacis.common.util.ExtractSchematron.java
private void processDatatypeAnnotation(XSAnnotation annotation, TypeUsage typeUsage, Writer out) throws IOException { try {// w w w .ja v a 2s. c o m final Document doc = this.dfactory.newDocumentBuilder().newDocument(); annotation.writeAnnotation(doc, XSAnnotation.W3C_DOM_DOCUMENT); final NodeList result = (NodeList) this.patternExpr.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < result.getLength(); i++) { final Element patternElt = (Element) result.item(i); // the included schematron rules do not have text content in the assert, // which should be the human-readable version of the test. we will use // the pattern name instead, as it's the most descriptive thing we have final String name = patternElt.getAttribute("name"); // we know each pattern has a single rule and a single assert final Element assertElt = (Element) patternElt.getElementsByTagNameNS(SCH_NS, "assert").item(0); assertElt.setTextContent(name); final String test = assertElt.getAttribute("test"); final String test2 = test.replaceAll(ELEMENT_REGEXP, "$1hl7:$2"); assertElt.setAttribute("test", test2); final Element ruleElt = (Element) patternElt.getElementsByTagNameNS(SCH_NS, "rule").item(0); typeUsage.getRuleIds().add(ruleElt.getAttribute("id")); writeNode(ruleElt, out); out.write("\n"); } } catch (final XPathExpressionException e) { LOG.error("Could not extract rules", e); } catch (final ParserConfigurationException e) { LOG.error("Could not extract rules", e); } catch (final TransformerException e) { LOG.error("Could not extract rules", e); } }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public Element setConsignor(String sPremName, String sName, String sPhone) { if (!isValidDoc()) return null; Element consignor = null;/* ww w . jav a2 s.c o m*/ consignor = childElementByName(root, "Consignor"); if (consignor == null) { consignor = doc.createElement("Consignor"); Node after = childNodeByNames(root, "Consignee,Accessions,Animal,GroupLot,Attachment"); root.insertBefore(consignor, after); Element premName = doc.createElement("PremName"); consignor.appendChild(premName); premName.setTextContent(sPremName); Element person = doc.createElement("Person"); consignor.appendChild(person); Element name = doc.createElement("Name"); person.appendChild(name); name.setTextContent(sName); if (sPhone != null && sPhone.trim().length() > 0) { Element phone = doc.createElement("Phone"); person.appendChild(phone); phone.setAttribute("Type", "Unknown"); phone.setAttribute("Number", sPhone); } } return consignor; }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public Element setConsignee(String sPremName, String sName, String sPhone) { if (isValidDoc()) return null; Element consignee = null;/*from w ww . j ava 2 s .c o m*/ consignee = childElementByName(root, "Consignee"); if (consignee == null) { consignee = doc.createElement("Consignee"); Node after = childNodeByNames(root, "Accessions,Animal,GroupLot,Attachment"); root.insertBefore(consignee, after); Element premName = doc.createElement("PremName"); consignee.appendChild(premName); premName.setTextContent(sPremName); Element person = doc.createElement("Person"); consignee.appendChild(person); Element name = doc.createElement("Name"); person.appendChild(name); name.setTextContent(sName); if (sPhone != null && sPhone.trim().length() > 0) { Element phone = doc.createElement("Phone"); person.appendChild(phone); phone.setAttribute("Type", "Unknown"); phone.setAttribute("Number", sPhone); } } return consignee; }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public Element setOrigin(String sPIN, String sPremName, String sName, String sPhone) { if (!isValidDoc()) return null; Element origin = null;// w w w . j av a 2s. c o m origin = childElementByName(root, "Origin"); if (origin == null) { origin = doc.createElement("Origin"); Node after = childNodeByNames(root, "Destination,Consignor,Consignee,Accessions,Animal,GroupLot,Attachment"); root.insertBefore(origin, after); if (sPIN != null && sPIN.trim().length() > 0) { Element pin = doc.createElement("PremId"); origin.appendChild(pin); pin.setTextContent(sPIN); } if (sPremName != null && sPremName.trim().length() > 0) { Element premName = doc.createElement("PremName"); origin.appendChild(premName); premName.setTextContent(sPremName); } Element person = doc.createElement("Person"); origin.appendChild(person); Element name = doc.createElement("Name"); person.appendChild(name); name.setTextContent(sName); if (sPhone != null && sPhone.trim().length() > 0) { Element phone = doc.createElement("Phone"); person.appendChild(phone); phone.setAttribute("Type", "Unknown"); phone.setAttribute("Number", sPhone); } } return origin; }
From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java
public Element setDestination(String sPIN, String sPremName, String sName, String sPhone) { if (!isValidDoc()) return null; Element destination = null;//from w w w . j ava 2 s. com destination = childElementByName(root, "Destination"); if (destination == null) { destination = doc.createElement("Destination"); Node after = childNodeByNames(root, "Consignor,Consignee,Accessions,Animal,GroupLot,Attachment"); root.insertBefore(destination, after); if (sPIN != null && sPIN.trim().length() > 0) { Element pin = doc.createElement("PremId"); destination.appendChild(pin); pin.setTextContent(sPIN); } if (sPremName != null && sPremName.trim().length() > 0) { Element premName = doc.createElement("PremName"); destination.appendChild(premName); premName.setTextContent(sPremName); } Element person = doc.createElement("Person"); destination.appendChild(person); Element name = doc.createElement("Name"); person.appendChild(name); name.setTextContent(sName); if (sPhone != null && sPhone.trim().length() > 0) { Element phone = doc.createElement("Phone"); person.appendChild(phone); phone.setAttribute("Type", "Unknown"); phone.setAttribute("Number", sPhone); } } return destination; }
From source file:com.evolveum.midpoint.prism.schema.SchemaToDomProcessor.java
public Element addAnnotation(QName qname, boolean value, Element parent) { Element annotation = createElement(qname); parent.appendChild(annotation);//from w w w. j ava 2s.c o m annotation.setTextContent(Boolean.toString(value)); return annotation; }
From source file:be.fedict.eid.applet.service.signer.ooxml.OOXMLSignatureFacet.java
private void addSignatureTime(XMLSignatureFactory signatureFactory, Document document, String signatureId, List<XMLStructure> objectContent) { /*//www.j a va 2s.co m * SignatureTime */ Element signatureTimeElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:SignatureTime"); signatureTimeElement.setAttributeNS(Constants.NamespaceSpecNS, "xmlns:mdssi", OOXML_DIGSIG_NS); Element formatElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Format"); formatElement.setTextContent("YYYY-MM-DDThh:mm:ssTZD"); signatureTimeElement.appendChild(formatElement); Element valueElement = document.createElementNS(OOXML_DIGSIG_NS, "mdssi:Value"); Date now = this.clock.getTime(); DateTime dateTime = new DateTime(now.getTime(), DateTimeZone.UTC); DateTimeFormatter fmt = ISODateTimeFormat.dateTimeNoMillis(); String nowStr = fmt.print(dateTime); LOG.debug("now: " + nowStr); valueElement.setTextContent(nowStr); signatureTimeElement.appendChild(valueElement); List<XMLStructure> signatureTimeContent = new LinkedList<XMLStructure>(); signatureTimeContent.add(new DOMStructure(signatureTimeElement)); SignatureProperty signatureTimeSignatureProperty = signatureFactory .newSignatureProperty(signatureTimeContent, "#" + signatureId, "idSignatureTime"); List<SignatureProperty> signaturePropertyContent = new LinkedList<SignatureProperty>(); signaturePropertyContent.add(signatureTimeSignatureProperty); SignatureProperties signatureProperties = signatureFactory.newSignatureProperties(signaturePropertyContent, "id-signature-time-" + UUID.randomUUID().toString()); objectContent.add(signatureProperties); }
From source file:com.photon.phresco.util.ProjectUtils.java
private List<Element> configResourceList(String modulePath, String moduleArtifactId, Document doc) throws PhrescoException { List<Element> configList = new ArrayList<Element>(); Element directory = doc.createElement("directory"); directory.setTextContent("${phresco.src.root.dir}" + modulePath + "/" + moduleArtifactId); configList.add(directory);//from w w w .j a va 2s . c o m return configList; }
From source file:es.upm.fi.dia.oeg.sitemap4rdf.Generator.java
/** * Generates the URLsection of the sitemap file * @param loc string for the locTag value * @param doc the XML Document/*from www . ja v a 2 s . co m*/ * @param elem the Element for the url element */ private void generateURLSection(String loc, Document doc, Element elem) { try { Element urlElement = doc.createElement(urlTag); Element locElement = doc.createElement(locTag); locElement.setTextContent(loc); urlElement.appendChild(locElement); if (lastMod != null && !lastMod.isEmpty()) { Element lastModElement = doc.createElement(lastmodTag); lastModElement.setTextContent(lastMod); urlElement.appendChild(lastModElement); } if (changeFreq != null && !changeFreq.isEmpty()) { Element changeFreqElement = doc.createElement(changefreqTag); changeFreqElement.setTextContent(changeFreq); urlElement.appendChild(changeFreqElement); } elem.appendChild(urlElement); } catch (Exception e) { logger.debug("Exception ", e); System.err.println(e.getMessage()); System.exit(3); } }
From source file:com.photon.phresco.util.ProjectUtils.java
private List<Element> configList(String modulePath, String moduleGroupId, String moduleArtifactId, String moduleVersion, Document doc) throws PhrescoException { List<Element> configList = new ArrayList<Element>(); Element groupId = doc.createElement(GROUP_ID); groupId.setTextContent(moduleGroupId); Element artifactId = doc.createElement(ARTIFACT_ID); artifactId.setTextContent(moduleArtifactId); Element version = doc.createElement(VERSION); version.setTextContent(moduleVersion); Element type = doc.createElement(TYPE); type.setTextContent(ZIP);/*from w ww. j a v a 2 s . c o m*/ Element overWrite = doc.createElement(OVER_WRITE); overWrite.setTextContent(OVER_WIRTE_VALUE); Element outputDirectory = doc.createElement(OUTPUT_DIR); outputDirectory.setTextContent("${phresco.src.root.dir}" + modulePath); configList.add(groupId); configList.add(artifactId); configList.add(version); configList.add(type); configList.add(overWrite); configList.add(outputDirectory); return configList; }