The problem is that you are asking the dataset for RDF/XML.
Datasets include the named graphs. It needs TriG or N-Quads.
So you ask for RDF/XML, and content negotiation says "can't - here's nmy
default (which is N-Quads) and then the code ignores the Content-type
and forces RDF/XML. It then fails to parse.
This works for me - ask for the default graph:
"http://localhost:"+PORT+"/birch?default"
Below is that done twice - using RDFConnection and as in the example.
Fuseki logging is turned on which can help debug conneg.
Andy
public static void main(String[] args) throws Exception {
FusekiLogging.setLogging();
int PORT = WebLib.choosePort();
FusekiServer server = FusekiServer.create()
.port(PORT)
.verbose(true)
.add("/birch", DatasetFactory.createTxnMem())
.build();
server.start();
// Server startup.
Lib.sleep(100);
// Version 1
try (RDFConnection conn = RDFConnectionRemote
.create()
.destination("http://localhost:"+PORT+"/birch")
.acceptHeaderGraph("application/rdf+xml")
.build()) {
Model model = conn.fetch();
RDFDataMgr.write(System.out, model, Lang.RDFXML);
}
// Version 2
URL url = new URL("http://localhost:"+PORT+"/birch?default");
URLConnection conn = url.openConnection();
conn.setRequestProperty("Accept", "application/rdf+xml");
Model model = ModelFactory.createDefaultModel();
model.read(conn.getInputStream(), null);
// RDFDataMgr.read(model, conn.getInputStream(), Lang.RDFXML);
RDFDataMgr.write(System.out, model, Lang.RDFXML);
System.exit(0);
}