Hi,
I am sorry if this is a silly question, but I need some clarity (or another 
coffee already).

The following are Java strings, therefore \n is the new line character...

Java strings                 Turtle literals   N-Triples literals
-----------------------------------------------------------------
\"\"\"Hello \n World\"\"\"   legal             illegal
\"Hello \n World\"           illegal           illegal
\"\"\"Hello \\n World\"\"\"  legal             legal
\"Hello \\n World\"          legal             legal
\"Hello \u0010 World\"       legal             legal
-----------------------------------------------------------------

If someone tries to parse a Turtle | N-Triples file with a literal with the 
characters '\''n' in it, we have a RiotException:

org.openjena.riot.RiotException: [line: 1, col: 68] Broken token (newline): 
Hello
        at 
org.openjena.riot.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:125)
        at org.openjena.riot.lang.LangEngine.raiseException(LangEngine.java:169)
        at org.openjena.riot.lang.LangEngine.nextToken(LangEngine.java:116)
        at 
org.openjena.riot.lang.LangTurtleBase.predicateObjectItem(LangTurtleBase.java:307)
        at 
org.openjena.riot.lang.LangTurtleBase.predicateObjectList(LangTurtleBase.java:289)
        at 
org.openjena.riot.lang.LangTurtleBase.triples(LangTurtleBase.java:280)
        at 
org.openjena.riot.lang.LangTurtleBase.triplesSameSubject(LangTurtleBase.java:219)
        at 
org.openjena.riot.lang.LangTurtle.oneTopLevelElement(LangTurtle.java:46)
        at 
org.openjena.riot.lang.LangTurtleBase.runParser(LangTurtleBase.java:144)
        at org.openjena.riot.lang.LangBase.parse(LangBase.java:43)
        at org.openjena.riot.RiotLoader.datasetFromString(RiotLoader.java:79)
        at dev.Run2.main(Run2.java:47)

Example here:
https://raw.github.com/castagna/jena-examples/master/src/main/java/dev/Run2.java

I think this is the right behavior, since the new line character is not legal 
in a string literal in N-Triples | N-Quads files.
It must be escaped '\n' (in a Java string as "\\n" or \u0010).

Right?

Paolo

Reply via email to