Turtle parser misses prefix declarations
----------------------------------------

                 Key: JENA-51
                 URL: https://issues.apache.org/jira/browse/JENA-51
             Project: Jena
          Issue Type: Bug
          Components: Jena
            Reporter: Richard Cyganiak
            Priority: Minor


Jena's Turtle parser doesn't capture @prefix declarations in the prefix 
mapping. Any triples are parsed correctly, but model.getNsPrefixMap() and 
friends show an empty prefix mapping.

The N3 parser handles this correctly.

====== example code below =======

import com.hp.hpl.jena.rdf.model.*;

public class Test {
        public static void main(String[] args) {
                String s =
                        "@prefix ex1: <http://example.com/1#>.\n" +
                        "@prefix ex2: <http://example.com/2#>.\n" +
                        "ex1:A a ex1:B .";
                
                Model n3 = ModelFactory.createDefaultModel();
                System.out.println("Parsing with N3 parser and printing 
prefixes:");
                n3.read(new java.io.ByteArrayInputStream(s.getBytes()), null, 
"N3");
                System.out.println(n3.getNsPrefixMap());

                Model turtle = ModelFactory.createDefaultModel();
                System.out.println("Parsing with Turtle parser and printing 
prefixes:");
                turtle.read(new java.io.ByteArrayInputStream(s.getBytes()), 
null, "TURTLE");
                System.out.println(turtle.getNsPrefixMap());
        }
}


===== output ======

Parsing with N3 parser:
{ex2=http://example.com/2#, ex1=http://example.com/1#}
Parsing with Turtle parser:
{}


-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to