code: private void serializIt(final String resource, final Long revision, final OutputStream output,
          final boolean nodeid) throws JaxRxException, TTException {
          // Connection to treetank, creating a session
          ISession session = null;
          // INodeReadTrx rtx = null;
          try {
              session = mDatabase.getSession(new SessionConfiguration(resource, StandardSettings.KEY));
              // and creating a transaction
              // if (revision == null) {
              // rtx = session.beginReadTransaction();
              // } else {
              // rtx = session.beginReadTransaction(revision);
              // }
              final XMLSerializerBuilder builder;
              if (revision == null)
                  builder = new XMLSerializerBuilder(session, output);
              else
                  builder = new XMLSerializerBuilder(session, output, revision);
              builder.setREST(nodeid);
              builder.setID(nodeid);
              builder.setDeclaration(false);
              final XMLSerializer serializer = builder.build();
              serializer.call();
          } catch (final Exception exce) {
              throw new JaxRxException(exce);
          } finally {
              // closing the treetank storage
              WorkerHelper.closeRTX(null, session);
          }
      }
docs: The XML serializer to a given tnk file.
  
  @param resource
  The resource that has to be serialized.
  @param revision
  The revision of the document.
  @param output
  The output stream where we write the XML file.
  @param nodeid
  <code>true</code> when you want the result nodes with node
  id's. <code>false</code> otherwise.
  @throws WebApplicationException
  The exception occurred.
  @throws TTException