2

I'm using DotNetRDF (downloaded from BitBucket) to execute SPARQL queries, but I'm getting an exception when using a query with a property path:

The value of a variable in a Set cannot be changed

Here is a portion of the RDF, the SPARQL query, and the C# code that executes the query. I'd expect the query to return id/002 and id/003.

<owl:Class rdf:about="http://ex.info/id/001">
<rdfs:label xml:lang="en">example data</rdfs:label>
<rdfs:subClassOf>
    <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
            <rdf:Description rdf:about="http://ex.info/id/002"/>
            <rdf:Description rdf:about="http://ex.info/id/003"/>
            <owl:Restriction>
                <owl:onProperty rdf:resource="http://ex.info/id/004"/>
                <owl:someValuesFrom rdf:resource="http://ex.info/id/005"/>
            </owl:Restriction>
        </owl:intersectionOf>
    </owl:Class>
</rdfs:subClassOf>

prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> 
prefix owl:   <http://www.w3.org/2002/07/owl#> 
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 

select ?superclass where {
  <http://ex.info/id/001> (rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))* ?superclass .
  filter(!isBlank(?superclass))
}
public List<string> queryData2(string query)
    {
        IGraph g = new Graph();
        FileLoader.Load(g, filePath);
        SparqlResultSet results = (SparqlResultSet)g.ExecuteQuery(query);
        List<string> output = new List<string>();
        foreach (SparqlResult result in results)
        {
            output.Add(result.ToString());
        }
        return output;
    }
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
user3190242
  • 55
  • 1
  • 5
  • 1
    It would be helpful if you could see what is the simplest query that illustrates the problem you are seeing. Does it need the whole of the property path? Or some of it? – AndyS Jan 15 '14 at 11:45
  • I need all path where id/001 can go., but this rdf not only have subclass it have owl:intersectionOf... then query look like that follow by http://stackoverflow.com/questions/21092246/sparql-query-subclass-or-equivalentto – user3190242 Jan 15 '14 at 12:10
  • 1
    That's not what Andy was asking, can you simplify the property path in the query and still produce the error seen? – RobV Jan 15 '14 at 12:13
  • This is definitely some kind of bug in the property path engine - filed as [CORE-395](http://dotnetrdf.org/tracker/Issues/IssueDetail.aspx?id=395) – RobV Jan 15 '14 at 14:38
  • The new release with the fix is now available – RobV Jan 17 '14 at 10:50
  • This work one way ' (rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))* ?superclass .' but not work to reverse query like this ' ?subclass (rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))* .' – user3190242 Jan 19 '14 at 06:05

2 Answers2

2

So as noted in the comments this was indeed a bug in the property path engine - see CORE-395

Essentially the problem was that when dotNetRDF translated the paths for evaluation it was not correctly allocating temporary variables. This meant that the designated paths were not actually being properly evaluated which either led to the error you saw or to silently returning partial/incorrect results.

This is now fixed and will be included in the upcoming 1.0.3 release which will be out by the end of the week.

Edit

The 1.0.3 release with the fix was released on January 17th 2014 and is now available

RobV
  • 28,022
  • 11
  • 77
  • 119
0

I try and found something to solve this problem. by this This error occur when use complex symbol(ex. use | / *) like this

(rdfs:subClassOf|(owl:intersectionOf/rdf:rest*/rdf:first))*

After I separate my query like this

1. <http://ex.info/id/001> rdfs:subClassOf* ?superclass . 

this query all subclass. and secound

2. <http://ex.info/id/001> (rdfs:subClassOf/owl:intersectionOf/rdf:rest*/rdf:first)* ?superclass .

this query all rdf:Description under owl:intersectionOf of rdfs:subClassOf.

And use UNION to join together like this

select ?superclass where {
    {
        <http://ex.info/id/001> rdfs:subClassOf* ?superclass .  
    }
    UNION
    {
        <http://ex.info/id/001> (rdfs:subClassOf/owl:intersectionOf/rdf:rest*/rdf:first)* ?  superclass .
    }
    filter(!isBlank(?superclass))
}

output is

   ?superclass = http://ex.info/id/001,
   ?superclass = http://ex.info/id/001,
   ?superclass = http://ex.info/id/002,
   ?superclass = http://ex.info/id/003

it has tsame data remove by DISTINCT

All query are here.

prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> 
prefix owl:   <http://www.w3.org/2002/07/owl#> 
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 

select DISTINCT ?superclass where {
    {
        <http://ex.info/id/001> rdfs:subClassOf* ?superclass .  
    }
    UNION
    {
        <http://ex.info/id/001> (rdfs:subClassOf/owl:intersectionOf/rdf:rest*/rdf:first)* ?superclass .
    }
    filter(!isBlank(?superclass))
}
user3190242
  • 55
  • 1
  • 5
  • I don't think this is really an answer to the question, since it doesn't explain why the property path query (which looks like it should have the same results) produces the error. It's certainly a workaround, though. I think it might be better if you add this to your question and mention that this works, while the combined path doesn't. – Joshua Taylor Jan 15 '14 at 13:55
  • I cann't explain anything because I'm not good in sparql and DotNetRDF. I answer this because I try and found this query can give me what I want(for this question), no exception error and maybe this is some idea can help someone who has same problem. :) – user3190242 Jan 15 '14 at 14:06