Java Utililty Methods XML Attribute Create

List of utility methods to do XML Attribute Create

Description

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

Method

voidwriteAttribute(PrintWriter w, Attr attr, int depth)
write Attribute
w.write(attr.getName());
w.write('=');
Node c = attr.getFirstChild();
while (c != null) {
    w.write('"');
    writeNode(w, c, depth);
    w.write('"');
    c = c.getNextSibling();
...
voidwriteAttribute(XMLStreamWriter writer, String name, Object value)
write Attribute
if (value != null) {
    writer.writeAttribute(name, value.toString());
voidwriteAttribute(XMLStreamWriter xmlw, String name, String value)
write Attribute
if (!StringUtilisEmpty(value)) {
    xmlw.writeAttribute(name, value);
voidwriteAttributeEvent(XMLEvent event, XMLStreamWriter writer)
write Attribute Event
Attribute attr = (Attribute) event;
QName name = attr.getName();
String nsURI = name.getNamespaceURI();
String localName = name.getLocalPart();
String prefix = name.getPrefix();
String value = attr.getValue();
if (prefix != null) {
    writer.writeAttribute(prefix, nsURI, localName, value);
...
voidwriteAttributes(Node node, Writer out)
write Attributes
NamedNodeMap attributes = node.getAttributes();
for (int i = 0; i < attributes.getLength(); i++) {
    Node attribute = attributes.item(i);
    String name = attribute.getNodeName();
    if (!name.toLowerCase().startsWith("xmlns")) {
        out.write(" " + name + "=\"" + escapeHTMLAttribute(attribute.getNodeValue()) + "\"");
voidwriteBoolAttr(Element element, String attributeName, boolean value)
write Bool Attr
element.setAttribute(attributeName, Boolean.toString(value));
voidwriteOutAttributesForNode(String[][] attributes, Node node)
write Out Attributes For Node
if (attributes != null) {
    for (int n = 0; n < attributes.length; n++) {
        String key = attributes[n][0];
        String value = attributes[n][1];
        if ((key != null) && (value != null)) {
            Attr attNode = node.getOwnerDocument().createAttribute(key.toString());
            attNode.setNodeValue(value.toString());
            node.getAttributes().setNamedItem(attNode);
...
voidwriteSvgAttributes(XMLStreamWriter w, Supplier cssClass, Supplier fill, Supplier stroke)
Write common attributes to the XMLStreamWriter

if (cssClass != null) {
    w.writeAttribute("class", cssClass.get());
if (fill != null) {
    w.writeAttribute("fill", fill.get());
if (stroke != null) {
    w.writeAttribute("stroke", stroke.get());
...
voidwriteXmlAttribute(XMLStreamWriter out, String name, Date value)
DOCUMENTME.
String str = null;
if (value != null) {
    SimpleDateFormat format = (SimpleDateFormat) dateFormat.clone();
    str = format.format(value);
} else {
    str = "";
out.writeAttribute(name, str);
...