Refactoring rdfgenerators to remove duplicate code

Also prevents memory leak in JSONRDFGenerator from workspace hanging
around after generating rdf.