what is wrong with this insert statement, it show error : Encountered a DOT Token to terminate a Triple Pattern but there are too many Tokens to form a valid Triple Pattern

i think that is because United States consist of tow word may be, how can i solve it ?

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
        PREFIX owl: <http://www.w3.org/2002/07/owl#>
        PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
        PREFIX base: <http://www.owl-ontologies.com/news.owl#>

        INSERT DATA { GRAPH <http://www.owl-ontologies.com/mynews.owl>

      { base:"United States" rdf:type base:CCountry .base:"United States" base:name "United States"^^xsd:string. base:"United States" base:isCountryOf base:America. base:America base:hasCountry base:"United States". } }

asked 19 Feb '13, 18:24

mhdeyad's gravatar image

accept rate: 0%

The subject of a triple in a SPARQL pattern needs to be a valid IRI, either specified as an actual IRI reference (e.g. <http://www.owl-ontologies.com/news.owl#foo> or by specifying a valid prefixed name, (e.g. base:foo). However, base:"United States" is not a valid prefixed name, as prefixed names can not contain quotes or spaces.

The simplest way to solve the problem is to remove the double quotes, and replace the whitespace, for example with an underscore. See the section on IRI references in the official SPARQL grammar for more details on what is and is not allowed.

permanent link

answered 19 Feb '13, 23:13

Jeen%20Broekstra's gravatar image

Jeen Broekstra ♦
accept rate: 37%

Before anyone complains: of course the subject of a triple can also be a blank node, in which case it is not an IRI. But I reckon that's not relevant to this particular question :)

(19 Feb '13, 23:17) Jeen Broekstra ♦ Jeen%20Broekstra's gravatar image

Jeen, in SPARQL, the subject can even be a literal. Yes.

(23 Feb '13, 08:08) Antoine Zimm... ♦ Antoine%20Zimmermann's gravatar image

@Antoine Zimmermann, true, if somewhat silly. No triplestore will accept a SPARQL INSERT with a literal in the subject position, as it's not valid RDF.

(23 Feb '13, 15:15) Jeen Broekstra ♦ Jeen%20Broekstra's gravatar image

Your problem as Jeen points out is that the following is not valid:

base:"United States" rdf:type base:CCountry .

This is because the base:"United States" is not a valid prefixed name so dotNetRDF tokenizes that as base: and "United States" separately thus you end up with 4 terms in a triple pattern hence not a valid triple pattern.

This is exactly what the error message tells you

BTW the RdfParseException that you receive has a number of properties that will point you to where the error is so it is always worth catching this for debugging purposes. StartLine will get you the line the error occurs on and StartPosition the column at which it occurs.

permanent link

answered 20 Feb '13, 01:24

Rob%20Vesse's gravatar image

Rob Vesse ♦
accept rate: 29%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 19 Feb '13, 18:24

question was seen: 2,419 times

last updated: 23 Feb '13, 15:16