Java XML Attribute Create writeAttribute(XMLStreamWriter writer, String name, Object value)

Here you can find the source of writeAttribute(XMLStreamWriter writer, String name, Object value)

Description

write Attribute

License

Open Source License

Declaration

public static void writeAttribute(XMLStreamWriter writer, String name,
            Object value) throws XMLStreamException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2012 Firestar Software, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*from w w  w . j  ava  2  s. co  m*/
 *     Firestar Software, Inc. - initial API and implementation
 *
 * Author:
 *     Gabriel Oancea
 *
 *******************************************************************************/

import javax.xml.stream.*;

public class Main {
    public static void writeAttribute(XMLStreamWriter writer, String name,
            Object value) throws XMLStreamException {
        if (value != null) {
            writer.writeAttribute(name, value.toString());
        }
    }

    public static void writeAttribute(XMLStreamWriter writer, String name,
            Object value, String namespace) throws XMLStreamException {
        if (value != null) {
            writer.writeAttribute(namespace, name, value.toString());
        }
    }
}

Related

  1. createAttributeTable(Element e)
  2. createFillAttributeGraphics(Document d, boolean showColor, boolean showGradientColor, boolean showGradientRotation, boolean showImage)
  3. createFontAttributeGraphics(Document d, boolean showFamily, boolean showStyle, boolean showWeight, boolean showSize, boolean showDecoration, boolean showAlign, boolean showRotation)
  4. mapifyAttrs(Node node, Map overwrite)
  5. writeAttribute(PrintWriter w, Attr attr, int depth)
  6. writeAttribute(XMLStreamWriter xmlw, String name, String value)
  7. writeAttributeEvent(XMLEvent event, XMLStreamWriter writer)
  8. writeAttributes(Node node, Writer out)
  9. writeBoolAttr(Element element, String attributeName, boolean value)