You can use GATE APIs to load the documents from the datastore and then export them as GATE XML in the normal way (imports and exception handling omitted):
Gate.init();
DataStore ds = Factory.openDataStore("gate.creole.annic.SearchableDataStore", "file:/path/to/datastore");
List docIds = ds.getLrIds("gate.corpora.DocumentImpl");
for(Object id : docIds) {
Document d = (Document)Factory.createResource("gate.corpora.DocumentImpl",
gate.Utils.featureMap(DataStore.DATASTORE_FEATURE_NAME, ds,
DataStore.LR_ID_FEATURE_NAME, id));
try {
File outputFile = new File(...); // based on doc name, sequential number, etc.
DocumentStaxUtils.writeDocument(d, outputFile);
} finally {
Factory.deleteResource(d);
}
}
If you want to write the annotations as inline XML then replace DocumentStaxUtils.writeDocument
with something like
Set<String> types = new HashSet<String>();
types.add("Person");
types.add("Location"); // and whatever others you're interested in
FileUtils.write(outputFile, d.toXml(d.getAnnotations().get(types), true));
(I'm using FileUtils from Apache commons-io for convenience but you could equally handle opening and closing the file yourself).