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.activiti.designer.export.bpmn20.export.ServiceTaskExport.java

public static void createServiceTask(Object object, XMLStreamWriter xtw) throws Exception {
    ServiceTask serviceTask = (ServiceTask) object;
    // start ServiceTask element
    xtw.writeStartElement("serviceTask");
    xtw.writeAttribute("id", serviceTask.getId());
    if (StringUtils.isNotEmpty(serviceTask.getName())) {
        xtw.writeAttribute("name", serviceTask.getName());
    }/*from w w  w  .j  a  v  a2  s.  c o  m*/
    DefaultFlowExport.createDefaultFlow(serviceTask, xtw);
    AsyncActivityExport.createAsyncAttribute(serviceTask, xtw);
    ImplementationValueExport.writeImplementationValue(xtw, EXECUTION_LISTENER,
            serviceTask.getImplementationType(), serviceTask.getImplementation(), true);

    if (StringUtils.isNotEmpty(serviceTask.getResultVariableName())) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "resultVariableName",
                serviceTask.getResultVariableName());
    }

    boolean executionListenersAvailable = false;
    if (serviceTask.getExecutionListeners() != null && serviceTask.getExecutionListeners().size() > 0) {
        executionListenersAvailable = true;
    }

    boolean fieldExtensionsAvailable = false;
    if (serviceTask.getFieldExtensions() != null && serviceTask.getFieldExtensions().size() > 0) {

        for (FieldExtension fieldExtension : serviceTask.getFieldExtensions()) {
            if (fieldExtension.getFieldName() != null && fieldExtension.getFieldName().length() > 0
                    && fieldExtension.getExpression() != null && fieldExtension.getExpression().length() > 0) {

                fieldExtensionsAvailable = true;
                break;
            }
        }
    }

    if (executionListenersAvailable == true || fieldExtensionsAvailable == true) {
        xtw.writeStartElement("extensionElements");
    }

    ExecutionListenerExport.createExecutionListenerXML(serviceTask.getExecutionListeners(), false, xtw);

    FieldExtensionsExport.writeFieldExtensions(xtw, serviceTask.getFieldExtensions(), false);

    if (executionListenersAvailable == true || fieldExtensionsAvailable == true) {
        xtw.writeEndElement();
    }

    if (serviceTask.getCustomProperties() != null && serviceTask.getCustomProperties().size() > 0) {
        boolean firstCustomProperty = true;
        for (CustomProperty customProperty : serviceTask.getCustomProperties()) {
            if (ExtensionConstants.PROPERTY_ID_CUSTOM_SERVICE_TASK.equals(customProperty.getName())) {
                continue;
            }
            if (customProperty.getSimpleValue() == null || customProperty.getSimpleValue().length() == 0) {
                continue;
            }
            if (firstCustomProperty == true) {
                xtw.writeStartElement("extensionElements");
                firstCustomProperty = false;
            }
            xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE);
            xtw.writeAttribute("name", customProperty.getName());
            xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "string", ACTIVITI_EXTENSIONS_NAMESPACE);
            xtw.writeCharacters(customProperty.getSimpleValue());
            xtw.writeEndElement();
            xtw.writeEndElement();
        }
        if (firstCustomProperty == false) {
            xtw.writeEndElement();
        }
    }

    MultiInstanceExport.createMultiInstance(object, xtw);

    // end ServiceTask element
    xtw.writeEndElement();
}

From source file:org.activiti.designer.export.bpmn20.export.UserTaskExport.java

public static void createUserTask(Object object, XMLStreamWriter xtw) throws Exception {
    UserTask userTask = (UserTask) object;

    // start UserTask element
    xtw.writeStartElement("userTask");
    xtw.writeAttribute("id", userTask.getId());
    if (userTask.getName() != null) {
        xtw.writeAttribute("name", userTask.getName());
    }/* www  .j a  va 2 s . c om*/

    if (userTask.getDueDate() != null) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "dueDate",
                userTask.getDueDate().toString());
    }

    DefaultFlowExport.createDefaultFlow(userTask, xtw);
    AsyncActivityExport.createAsyncAttribute(userTask, xtw);

    if (userTask.getAssignee() != null && userTask.getAssignee().length() > 0) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "assignee",
                userTask.getAssignee());
    }

    if (userTask.getCandidateUsers().size() > 0) {
        Iterator<String> candidateUserIterator = userTask.getCandidateUsers().iterator();
        String candidateUsers = candidateUserIterator.next();
        while (candidateUserIterator.hasNext()) {
            candidateUsers += ", " + candidateUserIterator.next();
        }
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "candidateUsers",
                candidateUsers);
    }

    if (userTask.getCandidateGroups().size() > 0) {
        Iterator<String> candidateGroupIterator = userTask.getCandidateGroups().iterator();
        String candidateGroups = candidateGroupIterator.next();
        while (candidateGroupIterator.hasNext()) {
            candidateGroups += ", " + candidateGroupIterator.next();
        }
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "candidateGroups",
                candidateGroups);
    }

    if (StringUtils.isNotEmpty(userTask.getFormKey())) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "formKey",
                userTask.getFormKey());
    }

    if (StringUtils.isNotEmpty(userTask.getPriority())) {
        xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "priority",
                userTask.getPriority());
    }

    if (StringUtils.isNotEmpty(userTask.getDocumentation())) {
        xtw.writeStartElement("documentation");
        xtw.writeCharacters(userTask.getDocumentation());
        // end documentation element
        xtw.writeEndElement();
    }

    boolean extensionsElement = true;
    if (userTask.getFormProperties().size() > 0) {
        extensionsElement = false;
        xtw.writeStartElement("extensionElements");
    }

    FormPropertiesExport.createFormPropertiesXML(userTask.getFormProperties(), xtw);
    TaskListenerExport.createTaskListenerXML(userTask.getTaskListeners(), extensionsElement, xtw);

    if (extensionsElement == false) {
        xtw.writeEndElement();
    }

    MultiInstanceExport.createMultiInstance(object, xtw);

    // end UserTask element
    xtw.writeEndElement();
}

From source file:org.activiti.designer.export.srcm.export.MailTaskExport.java

private static void writeAlfrescoScriptMailTask(AlfrescoMailTask mailTask, XMLStreamWriter xtw)
        throws Exception {

    // start AlfrescoMailTask element
    xtw.writeStartElement("serviceTask");
    xtw.writeAttribute("id", mailTask.getId());
    if (mailTask.getName() != null) {
        xtw.writeAttribute("name", mailTask.getName());
    }/*  w w  w .  j  ava 2s .  c  o m*/
    xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "class",
            "org.alfresco.repo.workflow.activiti.script.AlfrescoScriptDelegate");
    DefaultFlowExport.createDefaultFlow(mailTask, xtw);
    AsyncActivityExport.createDefaultFlow(mailTask, xtw);

    xtw.writeStartElement("extensionElements");

    ExtensionListenerExport.createExtensionListenerXML(mailTask.getActivitiListeners(), false,
            EXECUTION_LISTENER, xtw);

    xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "field", ACTIVITI_EXTENSIONS_NAMESPACE);
    xtw.writeAttribute("name", "script");
    xtw.writeStartElement(ACTIVITI_EXTENSIONS_PREFIX, "string", ACTIVITI_EXTENSIONS_NAMESPACE);
    xtw.writeCharacters(createMailScript(mailTask));
    xtw.writeEndElement();
    xtw.writeEndElement();

    xtw.writeEndElement();

    MultiInstanceExport.createMultiInstance(mailTask, xtw);

    // end AlfrescoMailTask element
    xtw.writeEndElement();

    if (mailTask.getBoundaryEventRefs().size() > 0) {
        for (BoundaryEvent event : mailTask.getBoundaryEventRefs()) {
            BoundaryEventExport.createBoundaryEvent(event, xtw);
        }
    }
}

From source file:org.activiti.designer.export.srcm.export.MailTaskExport.java

private static void writeServiceMailTask(MailTask mailTask, XMLStreamWriter xtw) throws Exception {

    // start MailTask element
    xtw.writeStartElement("serviceTask");
    xtw.writeAttribute("id", mailTask.getId());
    if (mailTask.getName() != null) {
        xtw.writeAttribute("name", mailTask.getName());
    }//from  ww w.  j a v  a2s.c  om
    DefaultFlowExport.createDefaultFlow(mailTask, xtw);
    AsyncActivityExport.createDefaultFlow(mailTask, xtw);
    xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "type", "mail");

    xtw.writeStartElement("extensionElements");
    ExtensionListenerExport.createExtensionListenerXML(mailTask.getActivitiListeners(), false,
            EXECUTION_LISTENER, xtw);

    if (mailTask.getTo() != null && mailTask.getTo().length() > 0) {
        writeField("to", mailTask.getTo(), xtw);
    }
    if (mailTask.getFrom() != null && mailTask.getFrom().length() > 0) {
        writeField("from", mailTask.getFrom(), xtw);
    }
    if (mailTask.getSubject() != null && mailTask.getSubject().length() > 0) {
        writeField("subject", mailTask.getSubject(), xtw);
    }
    if (mailTask.getCc() != null && mailTask.getCc().length() > 0) {
        writeField("cc", mailTask.getCc(), xtw);
    }
    if (mailTask.getBcc() != null && mailTask.getBcc().length() > 0) {
        writeField("bcc", mailTask.getBcc(), xtw);
    }
    if (mailTask.getHtml() != null && mailTask.getHtml().length() > 0) {
        writeCDataField("html", mailTask.getHtml(), xtw);
    }
    if (mailTask.getText() != null && mailTask.getText().length() > 0) {
        writeCDataField("text", mailTask.getText(), xtw);
    }
    xtw.writeEndElement();

    MultiInstanceExport.createMultiInstance(mailTask, xtw);

    // end MailTask element
    xtw.writeEndElement();

    if (mailTask.getBoundaryEventRefs().size() > 0) {
        for (BoundaryEvent event : mailTask.getBoundaryEventRefs()) {
            BoundaryEventExport.createBoundaryEvent(event, xtw);
        }
    }
}

From source file:org.activiti.designer.export.srcm.export.MultiInstanceExport.java

public static void createMultiInstance(EObject object, XMLStreamWriter xtw) throws Exception {
    Activity activity = (Activity) object;
    if (activity.getLoopCharacteristics() == null)
        return;//  w  w w  .  ja  va 2  s .c o m

    MultiInstanceLoopCharacteristics multiInstanceDef = (MultiInstanceLoopCharacteristics) activity
            .getLoopCharacteristics();

    if (StringUtils.isNotEmpty(multiInstanceDef.getInputDataItem())
            || StringUtils.isNotEmpty(multiInstanceDef.getLoopCardinality())
            || StringUtils.isNotEmpty(multiInstanceDef.getCompletionCondition())) {

        // start multiInstance element
        xtw.writeStartElement("multiInstanceLoopCharacteristics");
        xtw.writeAttribute("isSequential", "" + multiInstanceDef.isIsSequential());
        if (multiInstanceDef.getInputDataItem() != null && multiInstanceDef.getInputDataItem().contains("${")) {
            xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "collection",
                    multiInstanceDef.getInputDataItem());
            if (multiInstanceDef.getElementVariable() != null
                    && multiInstanceDef.getElementVariable().length() > 0) {
                xtw.writeAttribute(ACTIVITI_EXTENSIONS_PREFIX, ACTIVITI_EXTENSIONS_NAMESPACE, "elementVariable",
                        multiInstanceDef.getElementVariable());
            }
        }
        if (StringUtils.isNotEmpty(multiInstanceDef.getLoopCardinality())) {
            xtw.writeStartElement("loopCardinality");
            xtw.writeCharacters(multiInstanceDef.getLoopCardinality());
            xtw.writeEndElement();
        }

        if (StringUtils.isNotEmpty(multiInstanceDef.getInputDataItem())
                && multiInstanceDef.getInputDataItem().contains("${") == false) {

            xtw.writeStartElement("loopDataInputRef");
            xtw.writeCharacters(multiInstanceDef.getInputDataItem());
            xtw.writeEndElement();

            if (StringUtils.isNotEmpty(multiInstanceDef.getElementVariable())) {
                xtw.writeStartElement("inputDataItem");
                xtw.writeAttribute("name", multiInstanceDef.getElementVariable());
                xtw.writeEndElement();
            }
        }

        if (StringUtils.isNotEmpty(multiInstanceDef.getCompletionCondition())) {
            xtw.writeStartElement("completionCondition");
            xtw.writeCharacters(multiInstanceDef.getCompletionCondition());
            xtw.writeEndElement();
        }

        // end multiInstance element
        xtw.writeEndElement();
    }
}

From source file:org.activiti.dmn.converter.util.DmnXMLUtil.java

public static void writeElementDescription(DmnElement dmnElement, XMLStreamWriter xtw) throws Exception {
    if (StringUtils.isNotEmpty(dmnElement.getDescription())
            && !"null".equalsIgnoreCase(dmnElement.getDescription())) {
        xtw.writeStartElement(ELEMENT_DESCRIPTION);
        xtw.writeCharacters(dmnElement.getDescription());
        xtw.writeEndElement();
    }/*w  w w .j a  v a  2 s .  co  m*/
}

From source file:org.activiti.dmn.converter.util.DmnXMLUtil.java

public static void writeExtensionElements(DmnElement dmnElement, XMLStreamWriter xtw) throws Exception {
    if (writeExtensionElements(dmnElement, false, xtw)) {
        xtw.writeEndElement();
    }// w  w w  .jav a 2  s .c  o  m
}

From source file:org.activiti.dmn.converter.util.DmnXMLUtil.java

protected static void writeExtensionElement(DmnExtensionElement extensionElement,
        Map<String, String> namespaceMap, XMLStreamWriter xtw) throws Exception {
    if (StringUtils.isNotEmpty(extensionElement.getName())) {
        Map<String, String> localNamespaceMap = new HashMap<String, String>();
        if (StringUtils.isNotEmpty(extensionElement.getNamespace())) {
            if (StringUtils.isNotEmpty(extensionElement.getNamespacePrefix())) {
                xtw.writeStartElement(extensionElement.getNamespacePrefix(), extensionElement.getName(),
                        extensionElement.getNamespace());

                if (namespaceMap.containsKey(extensionElement.getNamespacePrefix()) == false
                        || namespaceMap.get(extensionElement.getNamespacePrefix())
                                .equals(extensionElement.getNamespace()) == false) {

                    xtw.writeNamespace(extensionElement.getNamespacePrefix(), extensionElement.getNamespace());
                    namespaceMap.put(extensionElement.getNamespacePrefix(), extensionElement.getNamespace());
                    localNamespaceMap.put(extensionElement.getNamespacePrefix(),
                            extensionElement.getNamespace());
                }//www .jav a 2  s  .  com
            } else {
                xtw.writeStartElement(extensionElement.getNamespace(), extensionElement.getName());
            }
        } else {
            xtw.writeStartElement(extensionElement.getName());
        }

        for (List<DmnExtensionAttribute> attributes : extensionElement.getAttributes().values()) {
            for (DmnExtensionAttribute attribute : attributes) {
                if (StringUtils.isNotEmpty(attribute.getName()) && attribute.getValue() != null) {
                    if (StringUtils.isNotEmpty(attribute.getNamespace())) {
                        if (StringUtils.isNotEmpty(attribute.getNamespacePrefix())) {

                            if (namespaceMap.containsKey(attribute.getNamespacePrefix()) == false
                                    || namespaceMap.get(attribute.getNamespacePrefix())
                                            .equals(attribute.getNamespace()) == false) {

                                xtw.writeNamespace(attribute.getNamespacePrefix(), attribute.getNamespace());
                                namespaceMap.put(attribute.getNamespacePrefix(), attribute.getNamespace());
                            }

                            xtw.writeAttribute(attribute.getNamespacePrefix(), attribute.getNamespace(),
                                    attribute.getName(), attribute.getValue());
                        } else {
                            xtw.writeAttribute(attribute.getNamespace(), attribute.getName(),
                                    attribute.getValue());
                        }
                    } else {
                        xtw.writeAttribute(attribute.getName(), attribute.getValue());
                    }
                }
            }
        }

        if (extensionElement.getElementText() != null) {
            xtw.writeCharacters(extensionElement.getElementText());
        } else {
            for (List<DmnExtensionElement> childElements : extensionElement.getChildElements().values()) {
                for (DmnExtensionElement childElement : childElements) {
                    writeExtensionElement(childElement, namespaceMap, xtw);
                }
            }
        }

        for (String prefix : localNamespaceMap.keySet()) {
            namespaceMap.remove(prefix);
        }

        xtw.writeEndElement();
    }
}

From source file:org.activiti.dmn.xml.converter.DmnXMLConverter.java

public byte[] convertToXML(DmnDefinition model, String encoding) {
    try {//  w  w  w  .  j av  a 2s  . c om

        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();

        XMLOutputFactory xof = XMLOutputFactory.newInstance();
        OutputStreamWriter out = new OutputStreamWriter(outputStream, encoding);

        XMLStreamWriter writer = xof.createXMLStreamWriter(out);
        XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer);

        xtw.writeStartElement(ELEMENT_DEFINITIONS);
        xtw.writeDefaultNamespace(DMN_NAMESPACE);
        xtw.writeAttribute(ATTRIBUTE_ID, model.getId());
        if (StringUtils.isNotEmpty(model.getName())) {
            xtw.writeAttribute(ATTRIBUTE_NAME, model.getName());
        }
        xtw.writeAttribute(ATTRIBUTE_NAMESPACE, MODEL_NAMESPACE);

        DmnXMLUtil.writeElementDescription(model, xtw);
        DmnXMLUtil.writeExtensionElements(model, xtw);

        for (ItemDefinition itemDefinition : model.getItemDefinitions()) {
            xtw.writeStartElement(ELEMENT_ITEM_DEFINITION);
            xtw.writeAttribute(ATTRIBUTE_ID, itemDefinition.getId());
            if (StringUtils.isNotEmpty(itemDefinition.getName())) {
                xtw.writeAttribute(ATTRIBUTE_NAME, itemDefinition.getName());
            }

            DmnXMLUtil.writeElementDescription(itemDefinition, xtw);
            DmnXMLUtil.writeExtensionElements(itemDefinition, xtw);

            xtw.writeStartElement(ELEMENT_TYPE_DEFINITION);
            xtw.writeCharacters(itemDefinition.getTypeDefinition());
            xtw.writeEndElement();

            xtw.writeEndElement();
        }

        for (Decision decision : model.getDrgElements()) {
            xtw.writeStartElement(ELEMENT_DECISION);
            xtw.writeAttribute(ATTRIBUTE_ID, decision.getId());
            if (StringUtils.isNotEmpty(decision.getName())) {
                xtw.writeAttribute(ATTRIBUTE_NAME, decision.getName());
            }

            DmnXMLUtil.writeElementDescription(decision, xtw);
            DmnXMLUtil.writeExtensionElements(decision, xtw);

            DecisionTable decisionTable = decision.getDecisionTable();
            xtw.writeStartElement(ELEMENT_DECISION_TABLE);
            xtw.writeAttribute(ATTRIBUTE_ID, decisionTable.getId());

            if (decisionTable.getHitPolicy() != null) {
                xtw.writeAttribute(ATTRIBUTE_HIT_POLICY, decisionTable.getHitPolicy().toString());
            }

            DmnXMLUtil.writeElementDescription(decisionTable, xtw);
            DmnXMLUtil.writeExtensionElements(decisionTable, xtw);

            for (InputClause clause : decisionTable.getInputs()) {
                xtw.writeStartElement(ELEMENT_INPUT_CLAUSE);
                if (StringUtils.isNotEmpty(clause.getId())) {
                    xtw.writeAttribute(ATTRIBUTE_ID, clause.getId());
                }
                if (StringUtils.isNotEmpty(clause.getLabel())) {
                    xtw.writeAttribute(ATTRIBUTE_LABEL, clause.getLabel());
                }

                DmnXMLUtil.writeElementDescription(clause, xtw);
                DmnXMLUtil.writeExtensionElements(clause, xtw);

                if (clause.getInputExpression() != null) {
                    xtw.writeStartElement(ELEMENT_INPUT_EXPRESSION);
                    xtw.writeAttribute(ATTRIBUTE_ID, clause.getInputExpression().getId());

                    if (StringUtils.isNotEmpty(clause.getInputExpression().getTypeRef())) {
                        xtw.writeAttribute(ATTRIBUTE_TYPE_REF, clause.getInputExpression().getTypeRef());
                    }

                    if (StringUtils.isNotEmpty(clause.getInputExpression().getText())) {
                        xtw.writeStartElement(ELEMENT_TEXT);
                        xtw.writeCharacters(clause.getInputExpression().getText());
                        xtw.writeEndElement();
                    }

                    xtw.writeEndElement();
                }

                xtw.writeEndElement();
            }

            for (OutputClause clause : decisionTable.getOutputs()) {
                xtw.writeStartElement(ELEMENT_OUTPUT_CLAUSE);
                if (StringUtils.isNotEmpty(clause.getId())) {
                    xtw.writeAttribute(ATTRIBUTE_ID, clause.getId());
                }
                if (StringUtils.isNotEmpty(clause.getLabel())) {
                    xtw.writeAttribute(ATTRIBUTE_LABEL, clause.getLabel());
                }
                if (StringUtils.isNotEmpty(clause.getName())) {
                    xtw.writeAttribute(ATTRIBUTE_NAME, clause.getName());
                }
                if (StringUtils.isNotEmpty(clause.getTypeRef())) {
                    xtw.writeAttribute(ATTRIBUTE_TYPE_REF, clause.getTypeRef());
                }

                DmnXMLUtil.writeElementDescription(clause, xtw);
                DmnXMLUtil.writeExtensionElements(clause, xtw);

                xtw.writeEndElement();
            }

            for (DecisionRule rule : decisionTable.getRules()) {
                xtw.writeStartElement(ELEMENT_RULE);
                if (StringUtils.isNotEmpty(rule.getId())) {
                    xtw.writeAttribute(ATTRIBUTE_ID, rule.getId());
                }

                DmnXMLUtil.writeElementDescription(rule, xtw);
                DmnXMLUtil.writeExtensionElements(rule, xtw);

                for (RuleInputClauseContainer container : rule.getInputEntries()) {
                    xtw.writeStartElement(ELEMENT_INPUT_ENTRY);
                    xtw.writeAttribute(ATTRIBUTE_ID, container.getInputEntry().getId());

                    xtw.writeStartElement(ELEMENT_TEXT);
                    xtw.writeCharacters(container.getInputEntry().getText());
                    xtw.writeEndElement();

                    xtw.writeEndElement();
                }

                for (RuleOutputClauseContainer container : rule.getOutputEntries()) {
                    xtw.writeStartElement(ELEMENT_OUTPUT_ENTRY);
                    xtw.writeAttribute(ATTRIBUTE_ID, container.getOutputEntry().getId());

                    xtw.writeStartElement(ELEMENT_TEXT);
                    xtw.writeCharacters(container.getOutputEntry().getText());
                    xtw.writeEndElement();

                    xtw.writeEndElement();
                }

                xtw.writeEndElement();
            }

            xtw.writeEndElement();

            xtw.writeEndElement();
        }

        // end definitions root element
        xtw.writeEndElement();
        xtw.writeEndDocument();

        xtw.flush();

        outputStream.close();

        xtw.close();

        return outputStream.toByteArray();

    } catch (Exception e) {
        LOGGER.error("Error writing BPMN XML", e);
        throw new DmnXMLException("Error writing BPMN XML", e);
    }
}

From source file:org.apache.axiom.om.impl.serialize.StreamingOMSerializer.java

/**
 * Method serializeEndElement.//from w w  w . j a  va 2s  .c om
 *
 * @param writer
 * @throws XMLStreamException
 */
protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException {
    writer.writeEndElement();
}