Debugging Parsing Errors in Protégé - mdebellis/SemanticKG-Design GitHub Wiki
🧠 Debugging Protégé Parsing Errors
Eventually you will get an error due to a malformed file that Protégé can’t parse. If you use a streaming format other than RDF/XML, knowing where to find the information you need can save you a lot of time.
➤ The People Ontology with a Syntax Error
Unlike many other tools, Protégé doesn’t ask you what format to use when it opens an ontology file and doesn’t only use the format consistent with the file extension. So even though your file ends with .ttl Protégé will try RDF/XML and other streaming formats as well as Turtle. That’s fine -- except that, when it can’t parse a file, it throws up a window with 17 different tabs (there are lots of possible streaming formats) and it always defaults to RDF/XML. Even when the file ends in .ttl. To illustrate the issue, I took the people ontology and edited it in Notepad++ and removed the period after the definition for Kurt Gödel. You can find this bad version of the People Ontology here: People Ontology with Syntax Error
When I try to load this file into Protégé there is a syntax error due to the missing period and I get the following error message:
Figure 1: Protégé always defaults to RDF/XML when it can't parse a file
➤ Protégé Always Defaults to RDF/XML When it Can't Parse a File
This error message tells you nothing because right from the beginning Protégé can tell this is not a valid RDF/XML file so you get that error message about the prolog. It’s complaining that the beginning of the ontology file isn’t valid RDF/XML which of course it isn’t, since it's Turtle. The fix is simple. Click on the tab that corresponds to the actual format you are using. In this case, click on (14) Turtle Syntax. Then you should see:
Figure 2: Select the tab for the format you used (in this case Turtle) and you get a meaningful message
➤ A Meaningful Message
When you click on that you see a very useful message: that points you to line 2072 and the definition of the new individual Lisa Meitner. Protégé expected there to be a period before this new definition, which is exactly the problem. Figure 3 shows the file in Notepad++. You can see that Gödel needs a period after his definition and if you add the period your problem is solved. Now you can add the period back and the file will parse.
Figure 3: The Turtle message takes you right where the problem is
➤ Isn't This Obvious?
I can imagine some people are thinking this is obvious but for a lot of people (including me when this first happened) it isn't. Part of the problem I think is when you get a syntax error it can be kind of disconcerting. Then when you see a message that makes no sense the natural reaction is to panic rather than calmly analyze the message. If you search the the Protégé user support mail archive (which you can do here you will see many messages asking what "No content allowed in prolog" means.