Pregunta

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;
    }
¿Fue útil?

Solución

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

Otros consejos

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))
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top