Ejemplo n.º 1
0
  @Override
  public String toXML() {
    StringWriter xmlBuffer = new StringWriter();
    try {
      XMLOutputFactory outputFactory = StaxUtils.getXmlOutputFactory(true);
      XMLStreamWriter xmlWriter = outputFactory.createXMLStreamWriter(xmlBuffer);

      toXML(xmlWriter);
      xmlWriter.flush();
    } catch (XMLStreamException e) {
      throw new PublicException(BpmRuntimeError.SDT_FAILED_GENERATING_XML.raise(), e);
    } finally {
      xmlBuffer.flush();
    }

    return xmlBuffer.toString();
  }
Ejemplo n.º 2
0
  /** @return the parsed document */
  public static Document buildDocument(InputStream is) throws PublicException, IOException {
    Document doc = null;
    try {
      XMLInputFactory inputFactory = StaxUtils.getXmlInputFactory();
      XMLStreamReader xmlReader = inputFactory.createXMLStreamReader(is);

      try {
        doc = buildDocument(xmlReader);
      } finally {
        xmlReader.close();
      }
    } catch (XMLStreamException e) {
      throw new PublicException(BpmRuntimeError.SDT_FAILED_PARSING_XML_DOCUMENT.raise(), e);
    }

    return doc;
  }