Example usage for javax.xml.stream XMLStreamWriter writeEndElement

List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamWriter writeEndElement.

Prototype

public void writeEndElement() throws XMLStreamException;

Source Link

Document

Writes an end tag to the output relying on the internal state of the writer to determine the prefix and local name of the event.

Usage

From source file:org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession.java

private void writeGenericAlert(final XMLStreamWriter writer, final DMGenericAlert[] genAlerts)
        throws XMLStreamException {
    for (final DMGenericAlert genericAlert : genAlerts) {
        final String cmdID = String.valueOf(this.idGenerator.nextCmdID());
        final String alertCode = "1226"; //$NON-NLS-1$
        final DMMeta meta = new DMMeta();
        meta.put(DMMeta.TYPE, genericAlert.getType());
        meta.put(DMMeta.FORMAT, genericAlert.getFormat());
        meta.put(DMMeta.MARK, genericAlert.getMark());
        this.commandSends.put(cmdID, new Object[] { alertCode, genericAlert.getCorrelator(),
                new DMItem[] { new DMItem(null, genericAlert.getSource(), meta, genericAlert.getData()) } });
        writer.writeStartElement("Alert"); //$NON-NLS-1$
        // CHECKSTYLE:OFF (imbricated blocks)
        {// ww  w .j ava 2 s  .  c  o m
            writer.writeStartElement("CmdID"); //$NON-NLS-1$
            writer.writeCharacters(cmdID);
            writer.writeEndElement();
            writer.writeStartElement("Data"); //$NON-NLS-1$
            writer.writeCharacters(alertCode);
            writer.writeEndElement();
            if (genericAlert.getCorrelator() != null) {
                writer.writeStartElement("Correlator"); //$NON-NLS-1$
                writer.writeCharacters(genericAlert.getCorrelator());
                writer.writeEndElement();
            }
            writer.writeStartElement("Item"); //$NON-NLS-1$
            {
                if (genericAlert.getSource() != null) {
                    writer.writeStartElement("Source"); //$NON-NLS-1$
                    {
                        writer.writeStartElement("LocURI"); //$NON-NLS-1$
                        writer.writeCharacters(genericAlert.getSource());
                        writer.writeEndElement();
                    }
                    writer.writeEndElement();
                }
                writer.writeStartElement("Meta"); //$NON-NLS-1$
                {
                    writer.writeStartElement("Type"); //$NON-NLS-1$
                    writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                    writer.writeCharacters(genericAlert.getType());
                    writer.writeEndElement();
                    writer.writeStartElement("Format"); //$NON-NLS-1$
                    writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                    writer.writeCharacters(genericAlert.getFormat());
                    writer.writeEndElement();
                    writer.writeStartElement("Mark"); //$NON-NLS-1$
                    writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                    writer.writeCharacters(genericAlert.getMark());
                    writer.writeEndElement();
                }
                writer.writeEndElement();
                writer.writeStartElement("Data"); //$NON-NLS-1$
                writer.writeCharacters(genericAlert.getData());
                writer.writeEndElement();
            }
            writer.writeEndElement();
        }
        writer.writeEndElement();
    }
    // CHECKSTYLE:ON
}

From source file:org.eclipse.koneki.protocols.omadm.client.basic.DMBasicSession.java

private void writeReplace(final XMLStreamWriter writer, final DMNode[] nodes) throws XMLStreamException {
    if (this.devInfoNodes.length >= 1) {
        boolean sameFormat = true;
        boolean sameType = true;
        if (this.devInfoNodes.length >= 2) {
            for (int i = 1; i < this.devInfoNodes.length; ++i) {
                if (sameFormat && !this.devInfoNodes[i].getFormat().equals(this.devInfoNodes[0].getFormat())) {
                    sameFormat = false;/* w w  w .  ja v a2 s  .co m*/
                }
                if (sameType && !this.devInfoNodes[i].getType().equals(this.devInfoNodes[0].getType())) {
                    sameType = false;
                }
            }
        }
        writer.writeStartElement("Replace"); //$NON-NLS-1$
        // CHECKSTYLE:OFF (imbricated blocks)
        {
            writer.writeStartElement("CmdID"); //$NON-NLS-1$
            writer.writeCharacters(String.valueOf(this.idGenerator.nextCmdID()));
            writer.writeEndElement();
            if (sameFormat || sameType) {
                writer.writeStartElement("Meta"); //$NON-NLS-1$
                {
                    if (sameFormat) {
                        writer.writeStartElement("Format"); //$NON-NLS-1$
                        writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                        writer.writeCharacters(this.devInfoNodes[0].getFormat());
                        writer.writeEndElement();
                    }
                    if (sameType) {
                        writer.writeStartElement("Type"); //$NON-NLS-1$
                        writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                        writer.writeCharacters(this.devInfoNodes[0].getType());
                        writer.writeEndElement();
                    }
                }
                writer.writeEndElement();
            }
            for (final DMNode devInfoNode : this.devInfoNodes) {
                writer.writeStartElement("Item"); //$NON-NLS-1$
                {
                    writer.writeStartElement("Source"); //$NON-NLS-1$
                    {
                        writer.writeStartElement("LocURI"); //$NON-NLS-1$
                        writer.writeCharacters(devInfoNode.getURI());
                        writer.writeEndElement();
                    }
                    writer.writeEndElement();
                    if (!sameFormat || !sameType) {
                        writer.writeStartElement("Meta"); //$NON-NLS-1$
                        {
                            if (!sameFormat) {
                                writer.writeStartElement("Format"); //$NON-NLS-1$
                                writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                                writer.writeCharacters(devInfoNode.getFormat());
                                writer.writeEndElement();
                            }
                            if (!sameType) {
                                writer.writeStartElement("Type"); //$NON-NLS-1$
                                writer.writeAttribute("xmlns", "syncml:metinf"); //$NON-NLS-1$ //$NON-NLS-2$
                                writer.writeCharacters(devInfoNode.getType());
                                writer.writeEndElement();
                            }
                        }
                        writer.writeEndElement();
                    }
                    writer.writeStartElement("Data"); //$NON-NLS-1$
                    writer.writeCharacters(devInfoNode.getData());
                    writer.writeEndElement();
                }
                writer.writeEndElement();
            }
        }
        writer.writeEndElement();
        // CHECKSTYLE:ON
    }
}

From source file:org.eclipse.smila.datamodel.record.stax.RecordWriter.java

/**
 * end the current element, optionally append a newline.
 *
 * @param staxWriter//from  w  w  w.  j a  v  a2 s.c  o  m
 *          target XML stream
 * @throws XMLStreamException
 *           StAX error.
 */
private void writeEndElement(final XMLStreamWriter staxWriter) throws XMLStreamException {
    staxWriter.writeEndElement();
    newline(staxWriter);
}

From source file:org.exist.webdav.MiltonDocument.java

/**
 *  Serialize document properties// w  w  w. j av a 2s  . c o  m
 * 
 * @param writer STAX writer
 * @throws XMLStreamException Thrown when writing data failed
 */
public void writeXML(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeStartElement("exist", "document", "http://exist.sourceforge.net/NS/exist");
    writer.writeAttribute("name", resourceXmldbUri.lastSegment().toString());
    writer.writeAttribute("created", getXmlDateTime(existDocument.getCreationTime()));
    writer.writeAttribute("last-modified", getXmlDateTime(existDocument.getLastModified()));
    writer.writeAttribute("owner", existDocument.getOwnerUser());
    writer.writeAttribute("group", existDocument.getOwnerGroup());
    writer.writeAttribute("permissions", "" + existDocument.getPermissions().toString());
    writer.writeAttribute("size", "" + existDocument.getContentLength());
    writer.writeEndElement();
}

From source file:org.exist.webstart.JnlpWriter.java

/**
 * Write JNLP xml file to browser.//w w  w.  ja v  a 2s  . co m
 *
 * @param response Object for writing to end user.
 * @throws java.io.IOException
 */
void writeJnlpXML(JnlpJarFiles jnlpFiles, HttpServletRequest request, HttpServletResponse response)
        throws IOException {

    logger.debug("Writing JNLP file");

    // Format URL: "http://host:8080/CONTEXT/webstart/exist.jnlp"
    final String currentUrl = request.getRequestURL().toString();

    // Find BaseUrl http://host:8080/CONTEXT
    final int webstartPos = currentUrl.indexOf("/webstart");
    final String existBaseUrl = currentUrl.substring(0, webstartPos);

    // Find codeBase for jarfiles http://host:8080/CONTEXT/webstart/
    final String codeBase = existBaseUrl + "/webstart/";

    // Perfom sanity checks
    int counter = 0;
    for (final File jar : jnlpFiles.getAllWebstartJars()) {
        counter++; // debugging
        if (jar == null || !jar.exists()) {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "Missing Jar file! (" + counter + ")");
            return;
        }
    }

    // Find URL to connect to with client
    final String startUrl = existBaseUrl.replaceFirst("http:", "xmldb:exist:")
            .replaceFirst("https:", "xmldb:exist:").replaceAll("-", "%2D") + "/xmlrpc";

    //        response.setDateHeader("Last-Modified", mainJar.lastModified());
    response.setContentType("application/x-java-jnlp-file");
    try {
        final XMLStreamWriter writer = XMLOutputFactory.newInstance()
                .createXMLStreamWriter(response.getOutputStream());

        writer.writeStartDocument();
        writer.writeStartElement("jnlp");
        writer.writeAttribute("spec", "1.0+");
        writer.writeAttribute("codebase", codeBase);
        writer.writeAttribute("href", "exist.jnlp");

        writer.writeStartElement("information");

        writer.writeStartElement("title");
        writer.writeCharacters("eXist XML-DB client");
        writer.writeEndElement();

        writer.writeStartElement("vendor");
        writer.writeCharacters("exist-db.org");
        writer.writeEndElement();

        writer.writeStartElement("homepage");
        writer.writeAttribute("href", "http://exist-db.org");
        writer.writeEndElement();

        writer.writeStartElement("description");
        writer.writeCharacters("Integrated command-line and gui client, "
                + "entirely based on the XML:DB API and provides commands "
                + "for most database related tasks, like creating and "
                + "removing collections, user management, batch-loading " + "XML data or querying.");
        writer.writeEndElement();

        writer.writeStartElement("description");
        writer.writeAttribute("kind", "short");
        writer.writeCharacters("eXist XML-DB client");
        writer.writeEndElement();

        writer.writeStartElement("description");
        writer.writeAttribute("kind", "tooltip");
        writer.writeCharacters("eXist XML-DB client");
        writer.writeEndElement();

        writer.writeStartElement("icon");
        writer.writeAttribute("href", "jnlp_logo.jpg");
        writer.writeEndElement();

        writer.writeStartElement("icon");
        writer.writeAttribute("href", "jnlp_icon_128x128.gif");
        writer.writeAttribute("width", "128");
        writer.writeAttribute("height", "128");
        writer.writeEndElement();

        writer.writeStartElement("icon");
        writer.writeAttribute("href", "jnlp_icon_64x64.gif");
        writer.writeAttribute("width", "64");
        writer.writeAttribute("height", "64");
        writer.writeEndElement();

        writer.writeStartElement("icon");
        writer.writeAttribute("href", "jnlp_icon_32x32.gif");
        writer.writeAttribute("width", "32");
        writer.writeAttribute("height", "32");
        writer.writeEndElement();

        writer.writeEndElement(); // information

        writer.writeStartElement("security");
        writer.writeEmptyElement("all-permissions");
        writer.writeEndElement();

        // ----------

        writer.writeStartElement("resources");

        writer.writeStartElement("property");
        writer.writeAttribute("name", "jnlp.packEnabled");
        writer.writeAttribute("value", "true");
        writer.writeEndElement();

        writer.writeStartElement("j2se");
        writer.writeAttribute("version", "1.6+");
        writer.writeEndElement();

        for (final File jar : jnlpFiles.getAllWebstartJars()) {
            writer.writeStartElement("jar");
            writer.writeAttribute("href", jar.getName());
            writer.writeAttribute("size", "" + jar.length());
            writer.writeEndElement();
        }

        writer.writeEndElement(); // resources

        writer.writeStartElement("application-desc");
        writer.writeAttribute("main-class", "org.exist.client.InteractiveClient");

        writer.writeStartElement("argument");
        writer.writeCharacters("-ouri=" + startUrl);
        writer.writeEndElement();

        writer.writeStartElement("argument");
        writer.writeCharacters("--no-embedded-mode");
        writer.writeEndElement();

        if (request.isSecure()) {
            writer.writeStartElement("argument");
            writer.writeCharacters("--use-ssl");
            writer.writeEndElement();
        }

        writer.writeEndElement(); // application-desc

        writer.writeEndElement(); // jnlp

        writer.writeEndDocument();

        writer.flush();
        writer.close();

    } catch (final Throwable ex) {
        logger.error(ex);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, ex.getMessage());
    }

}

From source file:org.exoplatform.services.jcr.ext.artifact.ArtifactManagingServiceImpl.java

protected File createSingleMetadata(String groupId, String artifactId, String version)
        throws FileNotFoundException {
    File temp = null;//from w  w w.jav a2  s .c o m
    try {
        String filename = getUniqueFilename("maven-metadata.xml");
        temp = File.createTempFile(filename, null);

        OutputStream os = new FileOutputStream(temp);
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = factory.createXMLStreamWriter(os);
        try {
            writer.writeStartDocument("UTF-8", "1.0");
            writer.writeStartElement("metadata");

            writer.writeStartElement("groupId");
            writer.writeCharacters(groupId);
            writer.writeEndElement();

            writer.writeStartElement("artifactId");
            writer.writeCharacters(artifactId);
            writer.writeEndElement();

            writer.writeStartElement("version");
            writer.writeCharacters(version);
            writer.writeEndElement();

            writer.writeEndElement();
            writer.writeEndDocument();
        } finally {
            writer.flush();
            writer.close();
            os.close();
        }
    } catch (XMLStreamException e) {
        LOG.error("Error on creating metadata - XML", e);
    } catch (IOException e) {
        LOG.error("Error on creating metadata - FILE", e);
    }
    return (temp != null && temp.exists()) ? temp : null;
}

From source file:org.exoplatform.services.jcr.ext.artifact.ArtifactManagingServiceImpl.java

protected File createMultiMetadata(String groupId, String artifactId, String current_version,
        List<String> v_list) throws FileNotFoundException {
    File temp = null;/*w w w .ja va2  s  .c o  m*/
    try {
        String filename = getUniqueFilename("maven-metadata.xml");
        temp = File.createTempFile(filename, null);

        OutputStream os = new FileOutputStream(temp);
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        XMLStreamWriter writer = factory.createXMLStreamWriter(os);
        try {
            writer.writeStartDocument("UTF-8", "1.0");
            writer.writeStartElement("metadata");

            writer.writeStartElement("groupId");
            writer.writeCharacters(groupId);
            writer.writeEndElement();

            writer.writeStartElement("artifactId");
            writer.writeCharacters(artifactId);
            writer.writeEndElement();

            String elderVersion;
            if (v_list.size() > 0) {
                Collections.sort(v_list); // sort list
                elderVersion = v_list.get(0); // get first element
            } else
                elderVersion = current_version;
            v_list.add(current_version);

            writer.writeStartElement("version");
            writer.writeCharacters(elderVersion);
            writer.writeEndElement();

            writer.writeStartElement("versions");
            writer.writeStartElement("versioning");

            for (Iterator<String> iterator = v_list.iterator(); iterator.hasNext();) {
                writer.writeStartElement("version");
                writer.writeCharacters(iterator.next());
                writer.writeEndElement();
            }

            writer.writeEndElement();
            writer.writeEndElement();

            writer.writeEndElement();
            writer.writeEndDocument();
        } finally {
            writer.flush();
            writer.close();
            os.close();
        }
    } catch (XMLStreamException e) {
        LOG.error("Error on creating metadata - XML", e);
    } catch (IOException e) {
        LOG.error("Error on creating metadata - FILE", e);
    }
    return (temp != null && temp.exists()) ? temp : null;
}

From source file:org.flowable.bpmn.converter.BaseBpmnXMLConverter.java

public void convertToXML(XMLStreamWriter xtw, BaseElement baseElement, BpmnModel model) throws Exception {
    xtw.writeStartElement(getXMLElementName());
    boolean didWriteExtensionStartElement = false;
    writeDefaultAttribute(ATTRIBUTE_ID, baseElement.getId(), xtw);
    if (baseElement instanceof FlowElement) {
        writeDefaultAttribute(ATTRIBUTE_NAME, ((FlowElement) baseElement).getName(), xtw);
    }/*from   www .ja v a2 s. co  m*/

    if (baseElement instanceof FlowNode) {
        final FlowNode flowNode = (FlowNode) baseElement;
        if (flowNode.isAsynchronous()) {
            writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
            if (flowNode.isNotExclusive()) {
                writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE, xtw);
            }
        }

        if (baseElement instanceof Activity) {
            final Activity activity = (Activity) baseElement;
            if (activity.isForCompensation()) {
                writeDefaultAttribute(ATTRIBUTE_ACTIVITY_ISFORCOMPENSATION, ATTRIBUTE_VALUE_TRUE, xtw);
            }
            if (StringUtils.isNotEmpty(activity.getDefaultFlow())) {
                FlowElement defaultFlowElement = model.getFlowElement(activity.getDefaultFlow());
                if (defaultFlowElement instanceof SequenceFlow) {
                    writeDefaultAttribute(ATTRIBUTE_DEFAULT, activity.getDefaultFlow(), xtw);
                }
            }
        }

        if (baseElement instanceof Gateway) {
            final Gateway gateway = (Gateway) baseElement;
            if (StringUtils.isNotEmpty(gateway.getDefaultFlow())) {
                FlowElement defaultFlowElement = model.getFlowElement(gateway.getDefaultFlow());
                if (defaultFlowElement instanceof SequenceFlow) {
                    writeDefaultAttribute(ATTRIBUTE_DEFAULT, gateway.getDefaultFlow(), xtw);
                }
            }
        }
    }

    writeAdditionalAttributes(baseElement, model, xtw);

    if (baseElement instanceof FlowElement) {
        final FlowElement flowElement = (FlowElement) baseElement;
        if (StringUtils.isNotEmpty(flowElement.getDocumentation())) {

            xtw.writeStartElement(ELEMENT_DOCUMENTATION);
            xtw.writeCharacters(flowElement.getDocumentation());
            xtw.writeEndElement();
        }
    }

    didWriteExtensionStartElement = writeExtensionChildElements(baseElement, didWriteExtensionStartElement,
            xtw);
    didWriteExtensionStartElement = writeListeners(baseElement, didWriteExtensionStartElement, xtw);
    didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(baseElement,
            didWriteExtensionStartElement, model.getNamespaces(), xtw);
    if (baseElement instanceof Activity) {
        final Activity activity = (Activity) baseElement;
        FailedJobRetryCountExport.writeFailedJobRetryCount(activity, xtw);

    }

    if (didWriteExtensionStartElement) {
        xtw.writeEndElement();
    }

    if (baseElement instanceof Activity) {
        final Activity activity = (Activity) baseElement;
        MultiInstanceExport.writeMultiInstance(activity, xtw);

    }

    writeAdditionalChildElements(baseElement, model, xtw);

    xtw.writeEndElement();
}

From source file:org.flowable.bpmn.converter.BaseBpmnXMLConverter.java

protected boolean writeFormProperties(FlowElement flowElement, boolean didWriteExtensionStartElement,
        XMLStreamWriter xtw) throws Exception {

    List<FormProperty> propertyList = null;
    if (flowElement instanceof UserTask) {
        propertyList = ((UserTask) flowElement).getFormProperties();
    } else if (flowElement instanceof StartEvent) {
        propertyList = ((StartEvent) flowElement).getFormProperties();
    }//ww  w.j a va  2 s . c  o m

    if (propertyList != null) {

        for (FormProperty property : propertyList) {

            if (StringUtils.isNotEmpty(property.getId())) {

                if (didWriteExtensionStartElement == false) {
                    xtw.writeStartElement(ELEMENT_EXTENSIONS);
                    didWriteExtensionStartElement = true;
                }

                xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FORMPROPERTY,
                        FLOWABLE_EXTENSIONS_NAMESPACE);
                writeDefaultAttribute(ATTRIBUTE_FORM_ID, property.getId(), xtw);

                writeDefaultAttribute(ATTRIBUTE_FORM_NAME, property.getName(), xtw);
                writeDefaultAttribute(ATTRIBUTE_FORM_TYPE, property.getType(), xtw);
                writeDefaultAttribute(ATTRIBUTE_FORM_EXPRESSION, property.getExpression(), xtw);
                writeDefaultAttribute(ATTRIBUTE_FORM_VARIABLE, property.getVariable(), xtw);
                writeDefaultAttribute(ATTRIBUTE_FORM_DEFAULT, property.getDefaultExpression(), xtw);
                writeDefaultAttribute(ATTRIBUTE_FORM_DATEPATTERN, property.getDatePattern(), xtw);
                if (property.isReadable() == false) {
                    writeDefaultAttribute(ATTRIBUTE_FORM_READABLE, ATTRIBUTE_VALUE_FALSE, xtw);
                }
                if (property.isWriteable() == false) {
                    writeDefaultAttribute(ATTRIBUTE_FORM_WRITABLE, ATTRIBUTE_VALUE_FALSE, xtw);
                }
                if (property.isRequired()) {
                    writeDefaultAttribute(ATTRIBUTE_FORM_REQUIRED, ATTRIBUTE_VALUE_TRUE, xtw);
                }

                for (FormValue formValue : property.getFormValues()) {
                    if (StringUtils.isNotEmpty(formValue.getId())) {
                        xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_VALUE,
                                FLOWABLE_EXTENSIONS_NAMESPACE);
                        xtw.writeAttribute(ATTRIBUTE_ID, formValue.getId());
                        xtw.writeAttribute(ATTRIBUTE_NAME, formValue.getName());
                        xtw.writeEndElement();
                    }
                }

                xtw.writeEndElement();
            }
        }
    }

    return didWriteExtensionStartElement;
}

From source file:org.flowable.bpmn.converter.BaseBpmnXMLConverter.java

protected void writeTimerDefinition(Event parentEvent, TimerEventDefinition timerDefinition,
        XMLStreamWriter xtw) throws Exception {
    xtw.writeStartElement(ELEMENT_EVENT_TIMERDEFINITION);
    if (StringUtils.isNotEmpty(timerDefinition.getCalendarName())) {
        writeQualifiedAttribute(ATTRIBUTE_CALENDAR_NAME, timerDefinition.getCalendarName(), xtw);
    }//w  w w  .ja  v  a 2  s.c om
    boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(timerDefinition, false, xtw);
    if (didWriteExtensionStartElement) {
        xtw.writeEndElement();
    }
    if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) {
        xtw.writeStartElement(ATTRIBUTE_TIMER_DATE);
        xtw.writeCharacters(timerDefinition.getTimeDate());
        xtw.writeEndElement();

    } else if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) {
        xtw.writeStartElement(ATTRIBUTE_TIMER_CYCLE);

        if (StringUtils.isNotEmpty(timerDefinition.getEndDate())) {
            xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_END_DATE,
                    timerDefinition.getEndDate());
        }

        xtw.writeCharacters(timerDefinition.getTimeCycle());
        xtw.writeEndElement();

    } else if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) {
        xtw.writeStartElement(ATTRIBUTE_TIMER_DURATION);
        xtw.writeCharacters(timerDefinition.getTimeDuration());
        xtw.writeEndElement();
    }

    xtw.writeEndElement();
}