Java Utililty Methods XMLStreamWriter

List of utility methods to do XMLStreamWriter

Description

The list of methods to do XMLStreamWriter are organized into topic(s).

Method

XMLStreamWritergetXMLStreamWriter(final Writer writer)
Get the XML stream writer.
return XML_OUTPUT_FACTORY.createXMLStreamWriter(writer);
booleanisEntityExpansionLimitException(XMLStreamException e)
Tests whether the provided exception is an entity expansion exception.
return e.getMessage() != null && e.getMessage().matches(ENTITY_EXPANSION_EXCEPTION_MESSAGE);
booleanisPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix)
is Prefix Declared
boolean prefixDecl = false;
NamespaceContext nscontext = writer.getNamespaceContext();
Iterator prefixItr = nscontext.getPrefixes(nsUri);
while (prefixItr.hasNext()) {
    if (prefix.equals(prefixItr.next())) {
        prefixDecl = true;
        break;
return prefixDecl;
voidrenderPath(XMLStreamWriter writer, String pathData, String id, String style)
render Path
writer.writeStartElement("path");
if (id != null) {
    writer.writeAttribute("id", id);
writer.writeAttribute("d", pathData);
if (style != null) {
    writer.writeAttribute("class", style);
writer.writeEndElement();
voidserializeEndpart(XMLStreamWriter writer)
Method serializeEndpart.
writer.writeEndElement();
voidsetValueType(XMLStreamWriter xml, String dataType)
set Value Type
if (dataType.equals(String.class.getName())) {
    return;
if (dataType.startsWith("java.lang.")) {
    dataType = dataType.substring("java.lang.".length());
xml.writeAttribute(VALUE_TYPE, dataType);
voidwriteAttribute(XMLStreamWriter out, QName name, String value)
write Attribute
if (name.getNamespaceURI() == null || "".equals(name.getNamespaceURI()))
    out.writeAttribute(name.getLocalPart(), value);
else if (name.getPrefix() == null || "".equals(name.getPrefix()))
    out.writeAttribute(name.getNamespaceURI(), name.getLocalPart(), value);
else
    out.writeAttribute(name.getPrefix(), name.getNamespaceURI(), name.getLocalPart(), value);
voidwriteCharactersOrCDATA(XMLStreamWriter xsw, String string)
Write the given string to the given writer, using either writeCharacters or, if there are more than a few less than signs in the string (e.g.
if (containsEnoughLTs(string)) {
    Matcher m = CDATA_END_PATTERN.matcher(string);
    int startFrom = 0;
    while (m.find()) {
        xsw.writeCData(string.substring(startFrom, m.start()));
        xsw.writeCharacters("]]>");
        startFrom = m.end();
    if (startFrom == 0) {
        xsw.writeCData(string);
    } else if (startFrom < string.length()) {
        xsw.writeCData(string.substring(startFrom));
} else {
    xsw.writeCharacters(string);
voidwriteColorConfig(XMLStreamWriter writer, Boolean enabled, String error, String warn, String success, String required, String batch)
write Color Config
writer.writeStartElement("color-output");
writer.writeStartElement("enabled");
writer.writeCharacters(enabled.toString());
writer.writeEndElement(); 
if (!"".equals(error)) {
    writer.writeStartElement("error-color");
    writer.writeCharacters(error);
    writer.writeEndElement();
...
voidwriteComment(String comment, XMLStreamWriter xmlsw)
write Comment
xmlsw.writeComment(comment);