Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-908

Turtle output can be empty when graph contains cyclic blank node references

    XMLWordPrintableJSON

Details

    Description

      Discovered a bug in writing Turtle with the latest release, haven't checked whether it applies to past versions of ARQ.

      Simple test case using test data from the DAWG tests:

          @Test
          public void bnode_cycles() {
              Model m = RDFDataMgr.loadModel("testing/DAWG-Final/construct/data-ident.ttl");
              Assert.assertTrue(m.size() > 0);
              
              ByteArrayOutputStream output = new ByteArrayOutputStream();
              RDFDataMgr.write(output, m, Lang.TURTLE);
              
              ByteArrayInputStream input = new ByteArrayInputStream(output.toByteArray());
              System.out.println(new String(output.toByteArray(), Charset.forName("utf-8")));
              Model m2 = ModelFactory.createDefaultModel();
              RDFDataMgr.read(m2, input, Lang.TURTLE);
              Assert.assertTrue(m2.size() > 0);
              
              Assert.assertTrue(m.isIsomorphicWith(m2));
          }
      

      Debugging this I can see that the problem appears to lie in TurtleShell which refuses to write any triples because each subject appears as the object of some other triple. This creates a cycle resulting in no data being output.

      TurtleShell needs to detect and arbitrarily break the cycles such that it can output the data successfully.

      I'll commit this as a disabled test case in TestLangTurtle to make it easy to start debugging.

      Attachments

        Activity

          People

            andy Andy Seaborne
            rvesse Rob Vesse
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: