public void cdata(StringBuilder text) {
   try {
     out.writeCData(text.toString());
   } catch (XMLStreamException e) {
     throw new TxwException(e);
   }
 }
 public void writeCData(String data) throws XMLStreamException {
   data = StaxUtilities.normalizeNewlines(data);
   if (data != null) {
     data = data.replace("\n", lineSeparator);
   }
   writer.writeCData(data);
   wroteText = true;
 }
 private static void writeDataPath(DataPath path, XMLStreamWriter xtw) throws Exception {
   xtw.writeStartElement(ELEMENT_DATA_PATH);
   BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_ID, path.getId(), xtw);
   BpmnXMLUtil.writeDefaultAttribute(ATTRIBUTE_LANGUAGE, path.getLanguage(), xtw);
   BpmnXMLUtil.writeDefaultAttribute(
       ATTRIBUTE_EVALUATES_TO_TYPE_REF, path.getEvaluatesToTypeRef(), xtw);
   xtw.writeCData(path.getExpressionValue());
   xtw.writeEndElement();
 }
Example #4
0
 /**
  * Writes the relevant output.
  *
  * @param writer
  * @throws XMLStreamException
  */
 private void writeOutput(XMLStreamWriter writer) throws XMLStreamException {
   int type = getType();
   if (type == TEXT_NODE || type == SPACE_NODE) {
     writer.writeCharacters(this.getText());
   } else if (type == CDATA_SECTION_NODE) {
     writer.writeCData(this.getText());
   } else if (type == ENTITY_REFERENCE_NODE) {
     writer.writeEntityRef(this.getText());
   }
 }
Example #5
0
  private static void writeModel(final XMLStreamWriter writer, ModelMetaData model)
      throws XMLStreamException {
    writer.writeStartElement(Element.MODEL.getLocalName());
    writeAttribute(writer, Element.NAME.getLocalName(), model.getName());
    writeAttribute(writer, Element.TYPE.getLocalName(), model.getModelType().name());

    writeAttribute(writer, Element.VISIBLE.getLocalName(), String.valueOf(model.isVisible()));
    writeAttribute(writer, Element.PATH.getLocalName(), model.getPath());

    if (model.getDescription() != null) {
      writeElement(writer, Element.DESCRIPTION, model.getDescription());
    }
    writeProperties(writer, model.getProperties());

    // source mappings
    for (SourceMappingMetadata source : model.getSourceMappings()) {
      writer.writeStartElement(Element.SOURCE.getLocalName());
      writeAttribute(writer, Element.NAME.getLocalName(), source.getName());
      writeAttribute(
          writer, Element.SOURCE_TRANSLATOR_NAME_ATTR.getLocalName(), source.getTranslatorName());
      writeAttribute(
          writer,
          Element.SOURCE_CONNECTION_JNDI_NAME_ATTR.getLocalName(),
          source.getConnectionJndiName());
      writer.writeEndElement();
    }

    if (model.getSchemaSourceType() != null) {
      writer.writeStartElement(Element.METADATA.getLocalName());
      writeAttribute(writer, Element.TYPE.getLocalName(), model.getSchemaSourceType());
      writer.writeCData(model.getSchemaText());
      writer.writeEndElement();
    }

    // model validation errors
    for (Message ve : model.getMessages(false)) {
      writer.writeStartElement(Element.VALIDATION_ERROR.getLocalName());
      writeAttribute(
          writer, Element.VALIDATION_SEVERITY_ATTR.getLocalName(), ve.getSeverity().name());
      writeAttribute(writer, Element.PATH.getLocalName(), ve.getPath());
      writer.writeCharacters(ve.getValue());
      writer.writeEndElement();
    }
    writer.writeEndElement();
  }
Example #6
0
  private void encodeXhtml(XhtmlDt theDt, XMLStreamWriter theEventWriter)
      throws XMLStreamException {
    if (theDt == null || theDt.getValue() == null || getSuppressNarratives()) {
      return;
    }

    boolean firstElement = true;
    for (XMLEvent event : theDt.getValue()) {
      switch (event.getEventType()) {
        case XMLStreamConstants.ATTRIBUTE:
          Attribute attr = (Attribute) event;
          if (isBlank(attr.getName().getPrefix())) {
            if (isBlank(attr.getName().getNamespaceURI())) {
              theEventWriter.writeAttribute(attr.getName().getLocalPart(), attr.getValue());
            } else {
              theEventWriter.writeAttribute(
                  attr.getName().getNamespaceURI(), attr.getName().getLocalPart(), attr.getValue());
            }
          } else {
            theEventWriter.writeAttribute(
                attr.getName().getPrefix(),
                attr.getName().getNamespaceURI(),
                attr.getName().getLocalPart(),
                attr.getValue());
          }

          break;
        case XMLStreamConstants.CDATA:
          theEventWriter.writeCData(((Characters) event).getData());
          break;
        case XMLStreamConstants.CHARACTERS:
        case XMLStreamConstants.SPACE:
          String data = ((Characters) event).getData();
          theEventWriter.writeCharacters(data);
          break;
        case XMLStreamConstants.COMMENT:
          theEventWriter.writeComment(((Comment) event).getText());
          break;
        case XMLStreamConstants.END_ELEMENT:
          theEventWriter.writeEndElement();
          break;
        case XMLStreamConstants.ENTITY_REFERENCE:
          EntityReference er = (EntityReference) event;
          theEventWriter.writeEntityRef(er.getName());
          break;
        case XMLStreamConstants.NAMESPACE:
          Namespace ns = (Namespace) event;
          theEventWriter.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
          break;
        case XMLStreamConstants.START_ELEMENT:
          StartElement se = event.asStartElement();
          if (firstElement) {
            if (StringUtils.isBlank(se.getName().getPrefix())) {
              String namespaceURI = se.getName().getNamespaceURI();
              if (StringUtils.isBlank(namespaceURI)) {
                namespaceURI = "http://www.w3.org/1999/xhtml";
              }
              theEventWriter.writeStartElement(se.getName().getLocalPart());
              theEventWriter.writeDefaultNamespace(namespaceURI);
            } else {
              String prefix = se.getName().getPrefix();
              String namespaceURI = se.getName().getNamespaceURI();
              theEventWriter.writeStartElement(prefix, se.getName().getLocalPart(), namespaceURI);
              theEventWriter.writeNamespace(prefix, namespaceURI);
            }
            firstElement = false;
          } else {
            if (isBlank(se.getName().getPrefix())) {
              if (isBlank(se.getName().getNamespaceURI())) {
                theEventWriter.writeStartElement(se.getName().getLocalPart());
              } else {
                if (StringUtils.isBlank(se.getName().getPrefix())) {
                  theEventWriter.writeStartElement(se.getName().getLocalPart());
                  // theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI());
                } else {
                  theEventWriter.writeStartElement(
                      se.getName().getNamespaceURI(), se.getName().getLocalPart());
                }
              }
            } else {
              theEventWriter.writeStartElement(
                  se.getName().getPrefix(),
                  se.getName().getLocalPart(),
                  se.getName().getNamespaceURI());
            }
            for (Iterator<?> attrIter = se.getAttributes(); attrIter.hasNext(); ) {
              Attribute next = (Attribute) attrIter.next();
              theEventWriter.writeAttribute(next.getName().getLocalPart(), next.getValue());
            }
          }
          break;
        case XMLStreamConstants.DTD:
        case XMLStreamConstants.END_DOCUMENT:
        case XMLStreamConstants.ENTITY_DECLARATION:
        case XMLStreamConstants.NOTATION_DECLARATION:
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
        case XMLStreamConstants.START_DOCUMENT:
          break;
      }
    }
  }
 public void writeCData(String data) throws XMLStreamException {
   writer.writeCData(data);
 }
  @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());
    }

    xtw.writeAttribute(ATTRIBUTE_PROCESS_EXECUTABLE, Boolean.toString(process.isExecutable()));
    xtw.writeAttribute("isClosed", Boolean.toString(process.isClosed()));
    if (StringUtils.isNotEmpty(process.getProcessType())) {
      xtw.writeAttribute("processType", process.getProcessType());
    }

    if (process.getCandidateStarterUsers().size() > 0) {
      xtw.writeAttribute(
          ACTIVITI_EXTENSIONS_PREFIX,
          ACTIVITI_EXTENSIONS_NAMESPACE,
          ATTRIBUTE_PROCESS_CANDIDATE_USERS,
          BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterUsers()));
    }

    if (process.getCandidateStarterGroups().size() > 0) {
      xtw.writeAttribute(
          ACTIVITI_EXTENSIONS_PREFIX,
          ACTIVITI_EXTENSIONS_NAMESPACE,
          ATTRIBUTE_PROCESS_CANDIDATE_GROUPS,
          BpmnXMLUtil.convertToDelimitedString(process.getCandidateStarterGroups()));
    }

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

    if (!process.getDocumentations().isEmpty()) {
      for (Documentation documentation : process.getDocumentations()) {
        xtw.writeStartElement(ELEMENT_DOCUMENTATION);
        if (StringUtils.isNotEmpty(documentation.getId())) {
          writeDefaultAttribute(ATTRIBUTE_ID, documentation.getId(), xtw);
        }
        if (StringUtils.isNotEmpty(documentation.getTextFormat())) {
          writeDefaultAttribute(ATTRIBUTE_TEXTFORMAT, documentation.getTextFormat(), xtw);
        }
        if (StringUtils.isNotEmpty(documentation.getText())) {
          xtw.writeCData(documentation.getText());
        }
        xtw.writeEndElement();
      }
    }

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

    if (didWriteExtensionStartElement) {
      // closing extensions element
      xtw.writeEndElement();
    }
    if (process.getIoSpecification() != null) {
      BpmnXMLUtil.writeIOSpecification(process.getIoSpecification(), xtw);
    }

    LaneExport.writeLanes(process, xtw);
  }
 public void writeCData(java.lang.String data) throws XMLStreamException {
   baseWriter.writeCData(data);
 }