Java Utililty Methods XML Attribute Create

List of utility methods to do XML Attribute Create

  1. HOME
  2. Java
  3. X
  4. XML Attribute Create

Description

The list of methods to do XML Attribute Create are organized into topic(s).

Method

Attr createAttr(Element parent, String name, Object value)
create Attr
if (value == null)
 return null;
Attr a = parent.getOwnerDocument().createAttribute(name);
a.setNodeValue(value.toString());
parent.getAttributes().setNamedItem(a);
return a;
Attr createAttr(String attrName, String attrValue, Document document)
create Attr
if (attrName == null || attrName.length() == 0 || attrValue == null || document == null) {
 return null;
Attr attribute = document.createAttribute(attrName);
attribute.setValue(attrValue);
return attribute;
Element createAttribute(Document doc, String friendlyName, String samlNS, String samlPrefix, QName attrKey)
create Attribute
Element attrEle = doc.createElementNS(samlNS, samlPrefix + ":Attribute");
attrEle.setAttribute("Name", attrKey.getLocalPart());
attrEle.setAttribute("NameFormat", attrKey.getNamespaceURI());
if ((friendlyName != null) && (!friendlyName.trim().isEmpty())) {
 attrEle.setAttribute("FriendlyName", friendlyName);
return attrEle;
void createAttribute(Document doc, String nodeName, Map map)
create Attribute
Node node = doc.getElementsByTagName(nodeName).item(0);
if (node.getNodeType() == Node.ELEMENT_NODE) {
 Element element = (Element) node;
 for (Map.Entry<String, String> entry : map.entrySet()) {
 element.setAttribute(entry.getKey(), entry.getValue());
Attr createAttribute(Document document, String name, String value)
create Attribute
Attr attr = document.createAttribute(name);
attr.setTextContent(value);
return attr;
void createAttribute(String sName, String sValue, Node nParent)
This method creates an attribute with the given name and value.
if ((nParent != null) && (nParent instanceof Element)) {
 Element eParent = (Element) nParent;
 eParent.setAttribute(sName, sValue);
Map createAttributeTable(Element e)
create Attribute Table
Map<String, String> attributeTable = new HashMap<>();
NamedNodeMap attrs = e.getAttributes();
if (attrs != null) {
 int numAttrs = attrs.getLength();
 for (int i = 0; i < numAttrs; i++) {
 Node na = attrs.item(i);
 if (na.getNodeType() != Node.ATTRIBUTE_NODE) {
 continue;
...
Element createFillAttributeGraphics(Document d, boolean showColor, boolean showGradientColor, boolean showGradientRotation, boolean showImage)
create Fill Attribute Graphics
Element fillGraphics = d.createElement("fill");
if (showColor)
 fillGraphics.setAttribute("color", "#FF0000");
if (showGradientColor)
 fillGraphics.setAttribute("gradient-color", "#FFFFFF");
if (showGradientRotation)
 fillGraphics.setAttribute("gradient-rotation", "diagonal");
if (showImage)
...
Element createFontAttributeGraphics(Document d, boolean showFamily, boolean showStyle, boolean showWeight, boolean showSize, boolean showDecoration, boolean showAlign, boolean showRotation)
create Font Attribute Graphics
Element fontGraphics = d.createElement("font");
if (showFamily)
 fontGraphics.setAttribute("family", "arial,sans-serif");
if (showStyle)
 fontGraphics.setAttribute("style", "italic");
if (showWeight)
 fontGraphics.setAttribute("weight", "bold");
if (showSize)
...
Map mapifyAttrs(Node node, Map overwrite)
This grabs the attributes from a dom node and overwrites those values with those specified by the overwrite map.
Map<String, String> map = new HashMap<String, String>();
NamedNodeMap nnMap = node.getAttributes();
for (int i = 0; i < nnMap.getLength(); i++) {
 Node attr = nnMap.item(i);
 map.put(attr.getNodeName(), attr.getNodeValue());
if (overwrite != null) {
 for (Map.Entry<String, String> e : overwrite.entrySet()) {
...


AltStyle によって変換されたページ (->オリジナル) /