You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2011/03/01 15:18:36 UTC

[jira] Closed: (JENA-51) Turtle parser misses prefix declarations

     [ https://issues.apache.org/jira/browse/JENA-51?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andy Seaborne closed JENA-51.
-----------------------------


> 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
>            Assignee: Andy Seaborne
>            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