if (format == RDFFormat.NTRIPLES) {
rdfDocumentWriter = new NTriplesWriter(stringWriter);
} else if (format == RDFFormat.RDFXML) {
rdfDocumentWriter = new RdfXmlWriter(stringWriter);
} else {
rdfDocumentWriter = new TurtleWriter(stringWriter);
}
try {
for (Namespace namespace : Namespace.values()) {
rdfDocumentWriter.setNamespace(namespace.getName(), namespace.getURI());