List of usage examples for org.w3c.dom Attr setValue
public void setValue(String value) throws DOMException;
From source file:de.uzk.hki.da.metadata.MetadataStructure.java
private void addXmlNsToEDM(Document edmDoc, Element rootElement) { Attr xmlns_dc = edmDoc.createAttribute("xmlns:dc"); xmlns_dc.setValue(C.DC_NS.getURI()); rootElement.setAttributeNode(xmlns_dc); Attr xmlns_edm = edmDoc.createAttribute("xmlns:edm"); xmlns_edm.setValue(C.EDM_NS.getURI()); rootElement.setAttributeNode(xmlns_edm); Attr xmlns_dcterms = edmDoc.createAttribute("xmlns:dcterms"); xmlns_dcterms.setValue(C.DCTERMS_NS.getURI()); rootElement.setAttributeNode(xmlns_dcterms); Attr xmlns_rdf = edmDoc.createAttribute("xmlns:rdf"); xmlns_rdf.setValue(C.RDF_NS.getURI()); rootElement.setAttributeNode(xmlns_rdf); Attr xmlns_ore = edmDoc.createAttribute("xmlns:ore"); xmlns_ore.setValue(C.ORE_NS.getURI()); rootElement.setAttributeNode(xmlns_ore); }
From source file:de.uzk.hki.da.metadata.MetadataStructure.java
private void addNewElementToParent(PreservationSystem preservationSystem, String id, String elementName, String elementValue, Element parent, Document edmDoc) { Element eName = edmDoc.createElement(elementName); if (elementName.equals(C.EDM_HAS_VIEW) || elementName.equals(C.EDM_IS_PART_OF) || elementName.equals(C.EDM_HAS_PART) || elementName.equals(C.EDM_IS_SHOWN_BY) || elementName.equals(C.EDM_OBJECT)) { if (elementName.equals(C.EDM_IS_PART_OF) || elementName.equals(C.EDM_HAS_PART)) { elementValue = preservationSystem.getUrisCho() + "/" + elementValue; }//from w ww. j a va 2s . c o m Attr rdfResource = edmDoc.createAttribute("rdf:resource"); rdfResource.setValue(elementValue); eName.setAttributeNode(rdfResource); } else { eName.appendChild(edmDoc.createTextNode(elementValue)); } parent.appendChild(eName); }
From source file:com.amalto.core.history.accessor.UnaryFieldAccessor.java
@Override public void markModified(Marker marker) { Document domDocument = document.asDOM(); Element element = getElement(); if (element != null) { Attr newAttribute = domDocument.createAttribute(MODIFIED_MARKER_ATTRIBUTE); switch (marker) { case ADD: newAttribute.setValue(FieldUpdateAction.MODIFY_ADD_MARKER_VALUE); break; case UPDATE: newAttribute.setValue(FieldUpdateAction.MODIFY_UPDATE_MARKER_VALUE); break; case REMOVE: newAttribute.setValue(FieldUpdateAction.MODIFY_REMOVE_MARKER_VALUE); break; default:/*from w w w .j a va 2 s.c om*/ throw new IllegalArgumentException("No support for marker " + marker); //$NON-NLS-1$ } element.getAttributes().setNamedItem(newAttribute); } }
From source file:net.sourceforge.ajaxtags.tags.AjaxAnchorsTag.java
/** * Rewrite link. Change (or create) "onclick" attribute, set "href" attribute to * "javascript://nop/".//w w w . j av a 2s .com * * @param link * node of document with link * @param target * target of request */ protected final void rewriteLink(final Node link, final String target) { final NamedNodeMap map = link.getAttributes(); final Attr href = (Attr) map.getNamedItem("href"); if (href != null) { Attr onclick = (Attr) map.getNamedItem("onclick"); if (onclick == null) { onclick = link.getOwnerDocument().createAttribute("onclick"); map.setNamedItem(onclick); } onclick.setValue(getOnclickAjax(target, href.getValue(), getOptionsBuilder())); href.setValue("javascript://nop/"); } }
From source file:clus.statistic.RegressionStat.java
@Override public Element getPredictElement(Document doc) { Element stats = doc.createElement("RegressionStat"); NumberFormat fr = ClusFormat.SIX_AFTER_DOT; Attr examples = doc.createAttribute("examples"); examples.setValue(fr.format(m_SumWeight)); stats.setAttributeNode(examples);// w w w. j a va 2 s . c om for (int i = 0; i < m_NbAttrs; i++) { Element attr = doc.createElement("Target"); Attr name = doc.createAttribute("name"); name.setValue(m_Attrs[i].getName()); attr.setAttributeNode(name); double tot = getSumWeights(i); if (tot == 0) attr.setTextContent("?"); else attr.setTextContent(fr.format(getSumValues(i) / tot)); stats.appendChild(attr); } return stats; }
From source file:ch.entwine.weblounge.bridge.oaipmh.util.XmlGen.java
protected Node $a(String name, String value) { Attr a = document.createAttribute(name); a.setValue(value); return a; }
From source file:com.amalto.core.history.accessor.ManyFieldAccessor.java
public void markModified(Marker marker) { Document domDocument = document.asDOM(); Node collectionItemNode = getCollectionItemNode(); if (collectionItemNode != null) { Attr newAttribute = domDocument.createAttribute(MODIFIED_MARKER_ATTRIBUTE); switch (marker) { case ADD: newAttribute.setValue(FieldUpdateAction.MODIFY_ADD_MARKER_VALUE); break; case UPDATE: newAttribute.setValue(FieldUpdateAction.MODIFY_UPDATE_MARKER_VALUE); break; case REMOVE: newAttribute.setValue(FieldUpdateAction.MODIFY_REMOVE_MARKER_VALUE); break; default:/*from w w w. ja va 2s .com*/ throw new IllegalArgumentException("No support for marker " + marker); //$NON-NLS-1$ } collectionItemNode.getAttributes().setNamedItem(newAttribute); } }
From source file:com.amalto.core.history.accessor.AttributeAccessor.java
public void markModified(Marker marker) { Document domDocument = document.asDOM(); Node parentNode = parent.getNode(); if (parentNode != null) { Attr newAttribute = domDocument.createAttribute(MODIFIED_MARKER_ATTRIBUTE); switch (marker) { case ADD: newAttribute.setValue(FieldUpdateAction.MODIFY_ADD_MARKER_VALUE); break; case UPDATE: newAttribute.setValue(FieldUpdateAction.MODIFY_UPDATE_MARKER_VALUE); break; case REMOVE: newAttribute.setValue(FieldUpdateAction.MODIFY_REMOVE_MARKER_VALUE); break; default:/*from w w w. j a v a 2 s . c o m*/ throw new IllegalArgumentException("No support for marker " + marker); //$NON-NLS-1$ } parentNode.getAttributes().setNamedItem(newAttribute); } }
From source file:ch.entwine.weblounge.bridge.oaipmh.util.XmlGen.java
protected Node $aBlank(String name, String value) { if (StringUtils.isNotBlank(value)) { Attr a = document.createAttribute(name); a.setValue(value); return a; } else {// w w w. ja v a 2 s .co m return nodeZero(); } }
From source file:com.intuit.karate.Script.java
public static void evalXmlEmbeddedExpressions(Node node, ScriptContext context) { if (node.getNodeType() == Node.DOCUMENT_NODE) { node = node.getFirstChild();/*from w w w . j a v a 2 s . com*/ } NamedNodeMap attribs = node.getAttributes(); int attribCount = attribs.getLength(); for (int i = 0; i < attribCount; i++) { Attr attrib = (Attr) attribs.item(i); String value = attrib.getValue(); value = StringUtils.trimToEmpty(value); if (isEmbeddedExpression(value)) { try { ScriptValue sv = evalInNashorn(value.substring(1), context); attrib.setValue(sv.getAsString()); } catch (Exception e) { logger.warn("embedded xml-attribute script eval failed: {}", e.getMessage()); } } } NodeList nodes = node.getChildNodes(); int childCount = nodes.getLength(); for (int i = 0; i < childCount; i++) { Node child = nodes.item(i); String value = child.getNodeValue(); if (value != null) { value = StringUtils.trimToEmpty(value); if (isEmbeddedExpression(value)) { try { ScriptValue sv = evalInNashorn(value.substring(1), context); child.setNodeValue(sv.getAsString()); } catch (Exception e) { logger.warn("embedded xml-text script eval failed: {}", e.getMessage()); } } } else if (child.hasChildNodes()) { evalXmlEmbeddedExpressions(child, context); } } }