code: private final OutputStream serialize(final String resource, final Long revision, final boolean nodeid,
          final OutputStream output, final boolean wrapResult) throws IOException, JaxRxException, TTException {
  
          if (mDatabase.existsResource(resource)) {
              try {
                  if (wrapResult) {
                      output.write(beginResult.getBytes());
                      serializIt(resource, revision, output, nodeid);
                      output.write(endResult.getBytes());
                  } else {
                      serializIt(resource, revision, output, nodeid);
                  }
              } catch (final Exception exce) {
                  throw new JaxRxException(exce);
              }
          } else {
              throw new JaxRxException(404, "Not found");
          }
  
          return output;
      }
docs: This method is responsible to build an {@link OutputStream} containing an
  XML file out of the TreeTank file.
  
  @param resource
  The name of the resource that will be offered as XML.
  @param nodeid
  To response the resource with a restid for each node ( <code>true</code>) or without (
  <code>false</code>).
  @param revision
  The revision of the requested resource. If <code>null</code>,
  than response the latest revision.
  @return The {@link OutputStream} containing the serialized XML file.
  @throws IOException
  @throws TTException
  @throws WebApplicationException