public static void writeRootElement(CmmnModel model, XMLStreamWriter xtw, String encoding) throws Exception { xtw.writeStartDocument(encoding, "1.0"); // start definitions root element xtw.writeStartElement(ELEMENT_DEFINITIONS); xtw.setDefaultNamespace(CMMN_NAMESPACE); xtw.writeDefaultNamespace(CMMN_NAMESPACE); xtw.writeNamespace(XSI_PREFIX, XSI_NAMESPACE); xtw.writeNamespace(FLOWABLE_EXTENSIONS_PREFIX, FLOWABLE_EXTENSIONS_NAMESPACE); xtw.writeNamespace(CMMNDI_PREFIX, CMMNDI_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)); } if (StringUtils.isNotEmpty(model.getTargetNamespace())) { xtw.writeAttribute(ATTRIBUTE_TARGET_NAMESPACE, model.getTargetNamespace()); } else { xtw.writeAttribute(ATTRIBUTE_TARGET_NAMESPACE, CASE_NAMESPACE); } } }
/** * Writes common elements like planItem documentation. * Subclasses should call super.writePlanItemDefinitionCommonElements(), it is recommended to override * writePlanItemDefinitionBody instead * * @param planItemDefinition the plan item definition to write * @param xtw the XML to write the definition to * @throws Exception in case of write exception */ protected boolean writePlanItemDefinitionCommonElements(CmmnModel model, T planItemDefinition, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(planItemDefinition.getDocumentation())) { xtw.writeStartElement(ELEMENT_DOCUMENTATION); xtw.writeCharacters(planItemDefinition.getDocumentation()); xtw.writeEndElement(); } return CmmnXmlUtil.writeExtensionElements(planItemDefinition, false, model.getNamespaces(), xtw); }
boolean didWriteExtensionElement = CmmnXmlUtil.writeExtensionElements(planItem, false, model.getNamespaces(), xtw); if (didWriteExtensionElement) { xtw.writeEndElement();