Example usage for javax.xml.stream XMLStreamWriter writeAttribute

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

Introduction

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

Prototype

public void writeAttribute(String localName, String value) throws XMLStreamException;

Source Link

Document

Writes an attribute to the output stream without a prefix.

Usage

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

/**
 *  Serialize document properties/*from w w  w  .  j a  v  a2 s. 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./*from   w  w w  .j a v  a  2 s  . c  om*/
 *
 * @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.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  . jav a  2s . c om

    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.BpmnXMLConverter.java

protected void createXML(FlowElement flowElement, BpmnModel model, XMLStreamWriter xtw) throws Exception {

    if (flowElement instanceof SubProcess) {

        SubProcess subProcess = (SubProcess) flowElement;
        if (flowElement instanceof Transaction) {
            xtw.writeStartElement(ELEMENT_TRANSACTION);
        } else if (flowElement instanceof AdhocSubProcess) {
            xtw.writeStartElement(ELEMENT_ADHOC_SUBPROCESS);
        } else {//www  .  j  ava 2 s.  co m
            xtw.writeStartElement(ELEMENT_SUBPROCESS);
        }

        xtw.writeAttribute(ATTRIBUTE_ID, subProcess.getId());
        if (StringUtils.isNotEmpty(subProcess.getName())) {
            xtw.writeAttribute(ATTRIBUTE_NAME, subProcess.getName());
        } else {
            xtw.writeAttribute(ATTRIBUTE_NAME, "subProcess");
        }

        if (subProcess instanceof EventSubProcess) {
            xtw.writeAttribute(ATTRIBUTE_TRIGGERED_BY, ATTRIBUTE_VALUE_TRUE);

        } else if (subProcess instanceof Transaction == false) {
            if (subProcess.isAsynchronous()) {
                BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_ASYNCHRONOUS, ATTRIBUTE_VALUE_TRUE, xtw);
                if (subProcess.isNotExclusive()) {
                    BpmnXMLUtil.writeQualifiedAttribute(ATTRIBUTE_ACTIVITY_EXCLUSIVE, ATTRIBUTE_VALUE_FALSE,
                            xtw);
                }
            }

        } else if (subProcess instanceof AdhocSubProcess) {
            AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
            BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_CANCEL_REMAINING_INSTANCES,
                    String.valueOf(adhocSubProcess.isCancelRemainingInstances()), xtw);
            if (StringUtils.isNotEmpty(adhocSubProcess.getOrdering())) {
                BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_ORDERING, adhocSubProcess.getOrdering(), xtw);
            }
        }

        if (StringUtils.isNotEmpty(subProcess.getDocumentation())) {

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

        boolean didWriteExtensionStartElement = FlowableListenerExport.writeListeners(subProcess, false, xtw);

        didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(subProcess,
                didWriteExtensionStartElement, model.getNamespaces(), xtw);
        if (didWriteExtensionStartElement) {
            // closing extensions element
            xtw.writeEndElement();
        }

        MultiInstanceExport.writeMultiInstance(subProcess, xtw);

        if (subProcess instanceof AdhocSubProcess) {
            AdhocSubProcess adhocSubProcess = (AdhocSubProcess) subProcess;
            if (StringUtils.isNotEmpty(adhocSubProcess.getCompletionCondition())) {
                xtw.writeStartElement(ELEMENT_COMPLETION_CONDITION);
                xtw.writeCData(adhocSubProcess.getCompletionCondition());
                xtw.writeEndElement();
            }
        }

        for (FlowElement subElement : subProcess.getFlowElements()) {
            createXML(subElement, model, xtw);
        }

        for (Artifact artifact : subProcess.getArtifacts()) {
            createXML(artifact, model, xtw);
        }

        xtw.writeEndElement();

    } else {

        BaseBpmnXMLConverter converter = convertersToXMLMap.get(flowElement.getClass());

        if (converter == null) {
            throw new XMLException("No converter for " + flowElement.getClass() + " found");
        }

        converter.convertToXML(xtw, flowElement, model);
    }
}

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

@Override
protected void writeAdditionalAttributes(BaseElement element, BpmnModel model, XMLStreamWriter xtw)
        throws Exception {
    CallActivity callActivity = (CallActivity) element;
    if (StringUtils.isNotEmpty(callActivity.getCalledElement())) {
        xtw.writeAttribute(ATTRIBUTE_CALL_ACTIVITY_CALLEDELEMENT, callActivity.getCalledElement());
    }//from   w w  w . j  a va2s  .c o m
    if (StringUtils.isNotEmpty(callActivity.getBusinessKey())) {
        writeQualifiedAttribute(ATTRIBUTE_CALL_ACTIVITY_BUSINESS_KEY, callActivity.getBusinessKey(), xtw);
    }
    if (callActivity.isInheritBusinessKey()) {
        writeQualifiedAttribute(ATTRIBUTE_CALL_ACTIVITY_INHERIT_BUSINESS_KEY, "true", xtw);
    }
    xtw.writeAttribute(FLOWABLE_EXTENSIONS_NAMESPACE, ATTRIBUTE_CALL_ACTIVITY_INHERITVARIABLES,
            String.valueOf(callActivity.isInheritVariables()));
}

From source file:org.flowable.bpmn.converter.export.BPMNDIExport.java

public static void writeBPMNDI(BpmnModel model, XMLStreamWriter xtw) throws Exception {
    // BPMN DI information
    xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_DIAGRAM, BPMNDI_NAMESPACE);

    String processId = null;/* ww w . java 2  s .  c  om*/
    if (!model.getPools().isEmpty()) {
        processId = "Collaboration";
    } else {
        processId = model.getMainProcess().getId();
    }

    xtw.writeAttribute(ATTRIBUTE_ID, "BPMNDiagram_" + processId);

    xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_PLANE, BPMNDI_NAMESPACE);
    xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, processId);
    xtw.writeAttribute(ATTRIBUTE_ID, "BPMNPlane_" + processId);

    for (String elementId : model.getLocationMap().keySet()) {

        if (model.getFlowElement(elementId) != null || model.getArtifact(elementId) != null
                || model.getPool(elementId) != null || model.getLane(elementId) != null) {

            xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_SHAPE, BPMNDI_NAMESPACE);
            xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId);
            xtw.writeAttribute(ATTRIBUTE_ID, "BPMNShape_" + elementId);

            GraphicInfo graphicInfo = model.getGraphicInfo(elementId);
            FlowElement flowElement = model.getFlowElement(elementId);
            if (flowElement instanceof SubProcess && graphicInfo.getExpanded() != null) {
                xtw.writeAttribute(ATTRIBUTE_DI_IS_EXPANDED, String.valueOf(graphicInfo.getExpanded()));
            }

            xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE);
            xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, "" + graphicInfo.getHeight());
            xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, "" + graphicInfo.getWidth());
            xtw.writeAttribute(ATTRIBUTE_DI_X, "" + graphicInfo.getX());
            xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + graphicInfo.getY());
            xtw.writeEndElement();

            xtw.writeEndElement();
        }
    }

    for (String elementId : model.getFlowLocationMap().keySet()) {

        if (model.getFlowElement(elementId) != null || model.getArtifact(elementId) != null
                || model.getMessageFlow(elementId) != null) {

            xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_EDGE, BPMNDI_NAMESPACE);
            xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId);
            xtw.writeAttribute(ATTRIBUTE_ID, "BPMNEdge_" + elementId);

            List<GraphicInfo> graphicInfoList = model.getFlowLocationGraphicInfo(elementId);
            for (GraphicInfo graphicInfo : graphicInfoList) {
                xtw.writeStartElement(OMGDI_PREFIX, ELEMENT_DI_WAYPOINT, OMGDI_NAMESPACE);
                xtw.writeAttribute(ATTRIBUTE_DI_X, "" + graphicInfo.getX());
                xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + graphicInfo.getY());
                xtw.writeEndElement();
            }

            GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(elementId);
            FlowElement flowElement = model.getFlowElement(elementId);
            MessageFlow messageFlow = null;
            if (flowElement == null) {
                messageFlow = model.getMessageFlow(elementId);
            }

            boolean hasName = false;
            if (flowElement != null && StringUtils.isNotEmpty(flowElement.getName())) {
                hasName = true;

            } else if (messageFlow != null && StringUtils.isNotEmpty(messageFlow.getName())) {
                hasName = true;
            }

            if (labelGraphicInfo != null && hasName) {
                xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_LABEL, BPMNDI_NAMESPACE);
                xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE);
                xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, "" + labelGraphicInfo.getHeight());
                xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, "" + labelGraphicInfo.getWidth());
                xtw.writeAttribute(ATTRIBUTE_DI_X, "" + labelGraphicInfo.getX());
                xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + labelGraphicInfo.getY());
                xtw.writeEndElement();
                xtw.writeEndElement();
            }

            xtw.writeEndElement();
        }
    }

    // end BPMN DI elements
    xtw.writeEndElement();
    xtw.writeEndElement();
}

From source file:org.flowable.bpmn.converter.export.DefinitionsRootExport.java

@SuppressWarnings("unchecked")
public static void writeRootElement(BpmnModel model, XMLStreamWriter xtw, String encoding) throws Exception {
    xtw.writeStartDocument(encoding, "1.0");

    // start definitions root element
    xtw.writeStartElement(ELEMENT_DEFINITIONS);
    xtw.setDefaultNamespace(BPMN2_NAMESPACE);
    xtw.writeDefaultNamespace(BPMN2_NAMESPACE);
    xtw.writeNamespace(XSI_PREFIX, XSI_NAMESPACE);
    xtw.writeNamespace(XSD_PREFIX, SCHEMA_NAMESPACE);
    xtw.writeNamespace(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE);
    xtw.writeNamespace(BPMNDI_PREFIX, BPMNDI_NAMESPACE);
    xtw.writeNamespace(OMGDC_PREFIX, OMGDC_NAMESPACE);
    xtw.writeNamespace(OMGDI_PREFIX, OMGDI_NAMESPACE);
    for (String prefix : model.getNamespaces().keySet()) {
        if (!defaultNamespaces.contains(prefix) && StringUtils.isNotEmpty(prefix))
            xtw.writeNamespace(prefix, model.getNamespaces().get(prefix));
    }//from w  ww.j  a  va  2  s .  com
    xtw.writeAttribute(TYPE_LANGUAGE_ATTRIBUTE, SCHEMA_NAMESPACE);
    xtw.writeAttribute(EXPRESSION_LANGUAGE_ATTRIBUTE, XPATH_NAMESPACE);
    if (StringUtils.isNotEmpty(model.getTargetNamespace())) {
        xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, model.getTargetNamespace());
    } else {
        xtw.writeAttribute(TARGET_NAMESPACE_ATTRIBUTE, PROCESS_NAMESPACE);
    }

    BpmnXMLUtil.writeCustomAttributes(model.getDefinitionsAttributes().values(), xtw, model.getNamespaces(),
            defaultAttributes);
}

From source file:org.flowable.bpmn.converter.export.LaneExport.java

public static void writeLanes(Process process, XMLStreamWriter xtw) throws Exception {
    if (!process.getLanes().isEmpty()) {
        xtw.writeStartElement(ELEMENT_LANESET);
        xtw.writeAttribute(ATTRIBUTE_ID, "laneSet_" + process.getId());
        for (Lane lane : process.getLanes()) {
            xtw.writeStartElement(ELEMENT_LANE);
            xtw.writeAttribute(ATTRIBUTE_ID, lane.getId());

            if (StringUtils.isNotEmpty(lane.getName())) {
                xtw.writeAttribute(ATTRIBUTE_NAME, lane.getName());
            }/*w  w w. j a v  a  2 s.c  om*/

            boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(lane, false, xtw);
            if (didWriteExtensionStartElement) {
                xtw.writeEndElement();
            }

            for (String flowNodeRef : lane.getFlowReferences()) {
                xtw.writeStartElement(ELEMENT_FLOWNODE_REF);
                xtw.writeCharacters(flowNodeRef);
                xtw.writeEndElement();
            }

            xtw.writeEndElement();
        }
        xtw.writeEndElement();
    }
}

From source file:org.flowable.bpmn.converter.export.ProcessExport.java

@SuppressWarnings("unchecked")
public static void writeProcess(Process process, XMLStreamWriter xtw) throws Exception {
    // start process element
    xtw.writeStartElement(ELEMENT_PROCESS);
    xtw.writeAttribute(ATTRIBUTE_ID, process.getId());

    if (StringUtils.isNotEmpty(process.getName())) {
        xtw.writeAttribute(ATTRIBUTE_NAME, process.getName());
    }//from  w  ww. j  av  a  2  s  . com

    xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable()));

    if (!process.getCandidateStarterUsers().isEmpty()) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_PROCESS_CANDIDATE_USERS,
                BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers()));
    }

    if (!process.getCandidateStarterGroups().isEmpty()) {
        xtw.writeAttribute(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE,
                ATTRIBUTE_PROCESS_CANDIDATE_GROUPS,
                BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups()));
    }

    // write custom attributes
    BpmnXMLUtil.writeCustomAttributes(process.getAttributes().values(), xtw, defaultProcessAttributes);

    if (StringUtils.isNotEmpty(process.getDocumentation())) {

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

    boolean didWriteExtensionStartElement = FlowableListenerExport.writeListeners(process, false, xtw);
    didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(process, didWriteExtensionStartElement,
            xtw);

    if (didWriteExtensionStartElement) {
        // closing extensions element
        xtw.writeEndElement();
    }

    LaneExport.writeLanes(process, xtw);
}

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

@Override
protected boolean writeExtensionChildElements(BaseElement element, boolean didWriteExtensionStartElement,
        XMLStreamWriter xtw) throws Exception {
    ServiceTask serviceTask = (ServiceTask) element;

    if (!serviceTask.getCustomProperties().isEmpty()) {
        for (CustomProperty customProperty : serviceTask.getCustomProperties()) {

            if (StringUtils.isEmpty(customProperty.getSimpleValue())) {
                continue;
            }/*from ww  w .jav a 2  s . c o  m*/

            if (didWriteExtensionStartElement == false) {
                xtw.writeStartElement(ELEMENT_EXTENSIONS);
                didWriteExtensionStartElement = true;
            }
            xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD, FLOWABLE_EXTENSIONS_NAMESPACE);
            xtw.writeAttribute(ATTRIBUTE_FIELD_NAME, customProperty.getName());
            if ((customProperty.getSimpleValue().contains("${")
                    || customProperty.getSimpleValue().contains("#{"))
                    && customProperty.getSimpleValue().contains("}")) {

                xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ATTRIBUTE_FIELD_EXPRESSION,
                        FLOWABLE_EXTENSIONS_NAMESPACE);
            } else {
                xtw.writeStartElement(FLOWABLE_EXTENSIONS_PREFIX, ELEMENT_FIELD_STRING,
                        FLOWABLE_EXTENSIONS_NAMESPACE);
            }
            xtw.writeCharacters(customProperty.getSimpleValue());
            xtw.writeEndElement();
            xtw.writeEndElement();
        }
    } else {
        didWriteExtensionStartElement = FieldExtensionExport
                .writeFieldExtensions(serviceTask.getFieldExtensions(), didWriteExtensionStartElement, xtw);
    }

    return didWriteExtensionStartElement;
}