List of usage examples for org.w3c.dom Element setAttribute
public void setAttribute(String name, String value) throws DOMException;
From source file:com.connexta.arbitro.utils.PolicyUtils.java
/** * This creates XML representation of attribute selector Element using AttributeSelectorDTO object * * @param attributeSelectorDTO AttributeSelectorDTO * @param doc Document//from w w w . j a v a 2s . com * @return DOM element */ public static Element createAttributeSelectorElement(AttributeSelectorDTO attributeSelectorDTO, Document doc) { Element attributeSelectorElement = doc.createElement(PolicyConstants.ATTRIBUTE_SELECTOR); if (attributeSelectorDTO.getAttributeSelectorRequestContextPath() != null && attributeSelectorDTO.getAttributeSelectorRequestContextPath().trim().length() > 0) { attributeSelectorElement.setAttribute(PolicyConstants.REQUEST_CONTEXT_PATH, PolicyConstants.ATTRIBUTE_NAMESPACE + attributeSelectorDTO.getAttributeSelectorRequestContextPath()); if (attributeSelectorDTO.getAttributeSelectorDataType() != null && attributeSelectorDTO.getAttributeSelectorDataType().trim().length() > 0) { attributeSelectorElement.setAttribute(PolicyConstants.DATA_TYPE, attributeSelectorDTO.getAttributeSelectorDataType()); } else { attributeSelectorElement.setAttribute(PolicyConstants.DATA_TYPE, PolicyConstants.STRING_DATA_TYPE); } if (attributeSelectorDTO.getAttributeSelectorMustBePresent() != null && attributeSelectorDTO.getAttributeSelectorMustBePresent().trim().length() > 0) { attributeSelectorElement.setAttribute(PolicyConstants.MUST_BE_PRESENT, attributeSelectorDTO.getAttributeSelectorMustBePresent()); } } return attributeSelectorElement; }
From source file:com.minhthuong.pfi.controller.PFIEditController.java
protected void doHeaders(RenderRequest request, RenderResponse response) { log.log(Level.INFO, "doHeaders.START"); Element cssElement = response.createElement("link"); cssElement.setAttribute("href", response.encodeURL("http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css")); 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); }
From source file:cz.mzk.editor.server.fedora.utils.FedoraUtils.java
/** * @param foxmlDocument//from ww w .j av a 2s . c o m * @param streamToModify * @param newContent */ private static void modifyStream(Document foxmlDocument, String streamToModify, String newContent) { if (newContent != null) { try { Element versionElement = foxmlDocument.createElement("foxml:datastreamVersion"); if (streamToModify.equals(RELS_EXT.getValue())) { versionElement.setAttribute("LABEL", "RDF Statements about this object"); versionElement.setAttribute("FORMAT_URI", RELS_EXT_NAMESPACE_URI); versionElement.setAttribute("MIMETYPE", "application/rdf+xml"); } else { versionElement.setAttribute("MIMETYPE", "text/xml"); if (streamToModify.equals(DC.getValue())) { versionElement.setAttribute("LABEL", "Dublin Core Record for this object"); versionElement.setAttribute("FORMAT_URI", OAI_DC_NAMESPACE_URI); } else if (streamToModify.equals(BIBLIO_MODS.getValue())) { versionElement.setAttribute("LABEL", "BIBLIO_MODS description of current object"); versionElement.setAttribute("FORMAT_URI", BIBILO_MODS_URI); } else if (streamToModify.equals(TEXT_OCR.getValue())) { versionElement.setAttribute("LABEL", ""); Element contLocElement = foxmlDocument.createElement("foxml:contentLocation"); contLocElement.setAttribute("TYPE", "INTERNAL_ID"); contLocElement.setAttribute("REF", "LOCAL"); Element localContElement = foxmlDocument.createElement("foxml:content"); localContElement.setTextContent(newContent); contLocElement.appendChild(localContElement); versionElement.appendChild(contLocElement); } } String lastStreamXPath = "//foxml:datastream[@ID=\'" + streamToModify + "\']/foxml:datastreamVersion[last()]"; Element element = FoxmlUtils.getElement(foxmlDocument, lastStreamXPath); int versionNumber = 0; if (element != null) { versionNumber = getVersionNumber(element.getAttribute("ID")); } versionElement.setAttribute("ID", streamToModify + "." + (versionNumber + 1)); versionElement.setAttribute("CREATED", "NOT YET"); versionElement.setAttribute("SIZE", "0"); Element contentElement = foxmlDocument.createElement("foxml:xmlContent"); try { InputStream is = new ByteArrayInputStream(newContent.getBytes("UTF-8")); Document newStreamDocument = FoxmlUtils.getFoxmlDocument(is); NodeList streamNodeList = newStreamDocument.getChildNodes(); for (int i = 0; i < streamNodeList.getLength(); i++) { Node myNewNode = foxmlDocument.importNode(streamNodeList.item(i), true); contentElement.appendChild(myNewNode); } } catch (IOException e) { System.err.println("IO fauilure" + e); } versionElement.appendChild(contentElement); String streamXPath = "//foxml:datastream[@ID=\'" + streamToModify + "\']"; Element parentOfStream = FoxmlUtils.getElement(foxmlDocument, streamXPath); if (parentOfStream == null) { String digObjXPath = "//foxml:digitalObject"; Element digObjElement = FoxmlUtils.getElement(foxmlDocument, digObjXPath); parentOfStream = foxmlDocument.createElement("datastream"); parentOfStream.setAttribute("ID", streamToModify); parentOfStream.setAttribute("STATE", "A"); //TODO for other streams if necessary if (streamToModify.equals(TEXT_OCR.getValue())) parentOfStream.setAttribute("CONTROL_GROUP", "M"); parentOfStream.setAttribute("VERSIONABLE", "false"); digObjElement.appendChild(parentOfStream); } parentOfStream.appendChild(versionElement); } catch (XPathExpressionException e) { LOGGER.warn("XPath failure", e); } } }
From source file:de.erdesignerng.model.serializer.CommonAbstractXMLSerializer.java
protected void serializeProperties(Document aDocument, Element aNode, ModelItem aItem) { aNode.setAttribute(ID, aItem.getSystemId()); aNode.setAttribute(NAME, aItem.getName()); for (String theKey : aItem.getProperties().getProperties().keySet()) { String theValue = aItem.getProperties().getProperties().get(theKey); if (theValue != null) { Element theProperty = addElement(aDocument, aNode, PROPERTY); theProperty.setAttribute(NAME, theKey); theProperty.setAttribute(VALUE, theValue); }/*from w w w .j a va 2s .c om*/ } }
From source file:fr.aliasource.webmail.book.ContactGroupsAction.java
public void execute(IProxy p, IParameterSource req, IResponder responder) { try {/*from ww w . ja v a2 s .c o m*/ Document doc = DOMUtils.createDoc("http://obm.aliasource.fr/xsd/contact_group", "contactGroups"); Element root = doc.getDocumentElement(); BookManager bm = BookActivator.getDefault().getBookManager(); List<ContactGroup> cgl = bm.getGroups(LoginUtils.lat(p.getAccount()), p.getAccount().getUserPassword()); for (ContactGroup cg : cgl) { Element cge = DOMUtils.createElement(root, "cg"); cge.setAttribute("id", cg.getId()); cge.setAttribute("d", cg.getDisplayName()); cge.setAttribute("count", new Integer(cg.getCount()).toString()); } responder.sendDom(doc); } catch (Exception e) { logger.error(e.getMessage(), e); } }
From source file:fr.aliasource.webmail.server.proxy.client.http.StoreHistoryMethod.java
private Document asXml(History history) throws ParserConfigurationException, FactoryConfigurationError { Document doc = DOMUtils.createDoc("http://minig.org/xsd/history.xsd", "history"); Element root = doc.getDocumentElement(); for (HistoryItem it : history) { Element item = DOMUtils.createElement(root, "item"); item.setAttribute("ts", "" + it.getTimestamp().getTime()); item.setAttribute("from", it.getFrom()); item.setTextContent(it.getText()); }/*from w w w. ja va 2 s. c o m*/ root.setAttribute("ts", "" + history.getLastChat().getTime()); return doc; }
From source file:com.minhthuong.pfi.controller.PFIEditController.java
@RequestMapping public String show(RenderRequest request, RenderResponse response) { log.log(Level.INFO, "show.edit.START"); Element cssElement = response.createElement("link"); cssElement.setAttribute("href", response.encodeURL("http://twitter.github.com/bootstrap/1.4.0/bootstrap.min.css")); 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); return "edit"; }
From source file:fr.aliasource.webmail.server.proxy.client.http.setting.SaveSignatureMethod.java
protected Document getSignaturesAsXML(Map<String, String> addrs) throws ParserConfigurationException, FactoryConfigurationError { Document doc = DOMUtils.createDoc("http://obm.aliasource.fr/xsd/signature_list", "signatureList"); Element root = doc.getDocumentElement(); for (Entry<String, String> addr : addrs.entrySet()) { Element fe = DOMUtils.createElement(root, "signature"); fe.setAttribute("email", addr.getKey()); fe.setTextContent(addr.getValue()); }/* w w w . j a v a 2s . com*/ return doc; }
From source file:com.nebhale.gpxconverter.StandardRouteBuilder.java
private Element trkpt(Document document, Point point) { Element trkpt = document.createElement("trkpt"); trkpt.setAttribute("lat", String.valueOf(point.getLatitude())); trkpt.setAttribute("lon", String.valueOf(point.getLongitude())); trkpt.appendChild(ele(document, point)); return trkpt; }
From source file:WpRDFFunctionLibrary.java
public static Document addWpProvenance(Document currentGPML, String wpIdentifier, String wpRevision) throws ParserConfigurationException, SAXException, IOException { Element pathwayElement = (Element) currentGPML.getElementsByTagName("Pathway").item(0); pathwayElement.setAttribute("identifier", wpIdentifier); pathwayElement.setAttribute("revision", wpRevision); return currentGPML; }