TripleStore store = new TripleStore();

store.LoadFromFile(Server.MapPath("CarInstances.rdf")); -- error


{"[Line 7 Column 14] Unexpected Character (Code 49) 1 was encountered"}

this is a file <?xml version="1.0" encoding="UTF-8"?> <rdf:rdf xmlns:car="Http://klzzwxh:0000 xmlns:usr=" http:="" klzzwxh:0001="" klzzwxh:0002="" 2002="" 07="" owl#"="" klzzwxh:0003="" 1999="" 02="" 22-rdf-syntax-ns#"="" klzzwxh:0004="" 2000="" 01="" rdf-schema#"=""> <rdf:description rdf:about="car:Car1"> <rdf:type> <rdf:description rdf:about="car:Car"/> </rdf:type> <car:carno>123456</car:carno> <car:model> Mitsubishi Lancer </car:model> <car:modelyear> 2006 </car:modelyear> <car:kind> #Sedan </car:kind> <car:color> #Blue </car:color> <car:kilometer> 40000</car:kilometer> <car:price> 800000 </car:price> <car:imager> Http://www.MyWebCar/Photo/Car1.jpg </car:imager> <car:phone>011-22323433</car:phone> <car:mobile> 0944345234</car:mobile> <car:createdby rdf:resource="usr:User1"/> </rdf:description> <rdf:description rdf:about="car:Car2"> <rdf:type> <rdf:description rdf:about="car:Car"/> </rdf:type> <car:carno>3452345</car:carno> <car:model> Toyota Corola </car:model> <car:modelyear> 2007 </car:modelyear> <car:kind> #Sedan </car:kind> <car:color> #Red </car:color> <car:kilometer> 60000</car:kilometer> <car:price> 850000 </car:price> <car:imager> Http://www.MyWebCar/Photo/Car2.jpg </car:imager> <car:phone>011-26876875</car:phone> <car:mobile> 0944687634</car:mobile> <car:createdby rdf:resource="usr:User2"/> </rdf:description> </rdf:rdf>

asked 19 Feb '12, 04:38

mhdeyad's gravatar image

accept rate: 0%

The LoadFromFile() method on a Triple store assumes a dataset file i.e. NQuads, TriG or TriX so when you try and load a RDF graph it assumes it is a dataset and uses the wrong parser.

What you want to do instead is the following:

TripleStore store = new TripleStore();
Graph g = new Graph();

The LoadFromFile() method on a Graph expects a graph file so will correctly recognize the format and select the correct parser.

permanent link

answered 19 Feb '12, 15:46

Rob%20Vesse's gravatar image

Rob Vesse ♦
accept rate: 29%

edited 19 Feb '12, 15:53


I realise that this behaviour is obviously confusing to new users so I have raised an issue for this (CORE-186) so that future versions of the API will behave more intuitively i.e. as @mhdeyad expected

(19 Feb '12, 19:27) Rob Vesse ♦ Rob%20Vesse's gravatar image

I do not know what's causing the error since your RDF/XML code validates, but I see a number of problems in your RDF file:

  1. www.CarOntology is not a valid domain name;
  2. Http://www.CarOntology/CarSchema# starts with a capital letter and it should not;
  3. many of the literal values are starting or ending with a space (so if I'm searching for a car made in 2006, for instance, I wouldn't find any because you've put a space in the value);
  4. it is not possible to use namespace prefixes inside the rdf:about or rdf:resource attribute values (e.g., rdf:about="car:Car1" should be replaced by rdf:about="Http://www.CarOntology/CarSchema#Car1");
  5. for the properties car:Color and car:Kind, you use a '#' in the literal values but it would make more sense to simply write "Blue" rather than " #Blue ", unless your intention was to use a URI, in which case it should be <car:Color rdf:resource="#Blue"/>.

Moreover, you could be more concise for the type declaration and simply write:

<rdf:type rdf:resource="Http://www.CarOntology/CarSchema#Car"/>

instead of:

  <rdf:Description rdf:about="car:Car"/>

Remark: I do not want to edit your code to format it better because maybe it's important to keep the exact source code, but this is what it looks like if formatted nicely:

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:car="Http://www.CarOntology/CarSchema#"
  <rdf:Description rdf:about="car:Car1">
      <rdf:Description rdf:about="car:Car"/>
    <car:Model> Mitsubishi Lancer </car:Model>
    <car:ModelYear> 2006 </car:ModelYear>
    <car:Kind> #Sedan </car:Kind>
    <car:Color> #Blue </car:Color>
    <car:KiloMeter> 40000</car:KiloMeter>
    <car:Price> 800000 </car:Price>
    <car:Imager> Http://www.MyWebCar/Photo/Car1.jpg </car:Imager>
    <car:Mobile> 0944345234</car:Mobile>
    <car:CreatedBy rdf:resource="usr:User1"/>
  <rdf:Description rdf:about="car:Car2">
      <rdf:Description rdf:about="car:Car"/>
    <car:Model> Toyota Corola </car:Model>
    <car:ModelYear> 2007 </car:ModelYear>
    <car:Kind> #Sedan </car:Kind>
    <car:Color> #Red </car:Color>
    <car:KiloMeter> 60000</car:KiloMeter>
    <car:Price> 850000 </car:Price>
    <car:Imager> Http://www.MyWebCar/Photo/Car2.jpg </car:Imager>
    <car:Mobile> 0944687634</car:Mobile>
    <car:CreatedBy rdf:resource="usr:User2"/>
permanent link

answered 19 Feb '12, 07:07

Antoine%20Zimmermann's gravatar image

Antoine Zimm... ♦
accept rate: 34%

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 '12, 04:38

question was seen: 1,133 times

last updated: 19 Feb '12, 19:27