A SPARQL query engine.
This class is based on the engine at http://sparql.sourceforge.net/ by Ryan Levering, version 0.8.
This example runs a SELECT query on a data source and writes the results as XML to standard output.
C# Example MemoryStore datamodel = new MemoryStore(new RdfXmlReader("rdfdata.rdf")); string sparqlQuery = "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n" + "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n" + "SELECT * WHERE { ?person rdf:type foaf:Agent . \n" + "?person foaf:name ?name . }"; SparqlEngine query = new SparqlEngine(sparqlQuery); query.Run(datamodel, Console.Out).Although this example sends the results to a stream, the results can be processed programmatically by passing a SemWeb.Query.QueryResultSink instead of a TextWriter.
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
See Also: Inherited members from Query.
⊟ Public Constructors
Initialized the SPARQL query from a TextReader. Initializes the SPARQL query from a string. ⊟ Public Fields
AllowPersistBNodes bool . Documentation for this section has not yet been entered. ⊟ Public Properties
MimeType string . Gets or sets the preferred MIME type for the output of the query. (Inherited from Query.) QueryMeta SemWeb.Entity . A filter on the Meta value of statements in the target graph considered by the query. (Inherited from Query.) ReturnLimit int . The number of bindings to return. (Inherited from Query.) ReturnStart int . The index of the first binding to return. (Inherited from Query.) [read-only] Type SparqlEngine.QueryType . Gets the type of the query. ⊟ Public Methods
AddExternalFunction (RdfFunction) Registers an external function that can be used in FILTER clauses.Ask (SemWeb.SelectableSource) : bool Executes an ASK query on the given data source and returns the result of the query as a boolean.Ask (SemWeb.SelectableSource, System.IO.TextWriter) Executes an ASK query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.Construct (SemWeb.SelectableSource, SemWeb.StatementSink) Executes a CONSTRUCT query on the given data source and sends the constructed statements to a StatementSink.Construct (SemWeb.SelectableSource, System.IO.TextWriter) Executes a CONSTRUCT query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.Describe (SemWeb.SelectableSource, SemWeb.StatementSink) Executes a DESCRIBE query on the given data source and sends the constructed statements to a StatementSink.Describe (SemWeb.SelectableSource, System.IO.TextWriter) Executes a DESCRIBE query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter. abstractGetExplanation () : string Returns a textual explanation of the query. (Inherited from Query.)GetQueryPrefixes () : SemWeb.NamespaceManager Gets a NamespaceManager containing all of the PREFIX definitions used in the query. abstractRun (SemWeb.SelectableSource, QueryResultSink) Runs the query on a data source, outputting to a QueryResultSink. (Inherited from Query.)Run (SemWeb.SelectableSource, System.IO.TextWriter) Runs the query on a data source, outputting to a TextWriter. (Inherited from Query.)Select (SemWeb.SelectableSource, QueryResultSink) Executes a SELECT query on the given data source and sends the resulting variable bindings to a QueryResultSink.Select (SemWeb.SelectableSource, System.IO.TextWriter) Executes a SELECT query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.
⊟ SparqlEngine Constructor
Initialized the SPARQL query from a TextReader.
public SparqlEngine (System.IO.TextReader query)⊟ Parameters
- query
- A TextReader containing the SPARQL query.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ SparqlEngine Constructor
Initializes the SPARQL query from a string.
public SparqlEngine (string query)⊟ Parameters
- query
- The SPARQL query.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ AddExternalFunction Method
Registers an external function that can be used in FILTER clauses.
public void AddExternalFunction (RdfFunction function)⊟ Parameters
- function
- An object implementing an external function.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ AllowPersistBNodes Field
Documentation for this section has not yet been entered.
public bool AllowPersistBNodes⊟ Remarks
Documentation for this section has not yet been entered.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Ask Method
Executes an ASK query on the given data source and returns the result of the query as a boolean.
public bool Ask (SemWeb.SelectableSource source)⊟ Parameters
- source
- The data source to query.
⊟ Returns
A boolean value giving the result of the ASK query.⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Ask Method
Executes an ASK query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.
⊟ Parameters
- source
- The data source to query.
- output
- The System.IO.TextWriter to output the results to in the SPARQL Results XML output format.
⊟ Remarks
This method can also be called through Query.Run(SemWeb.SelectableSource, System.IO.TextWriter).⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Construct Method
Executes a CONSTRUCT query on the given data source and sends the constructed statements to a StatementSink.
⊟ Parameters
- source
- The data source to query.
- sink
- The SemWeb.StatementSink to send the constructed statements to.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Construct Method
Executes a CONSTRUCT query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.
⊟ Parameters
- source
- The data source to query.
- output
- The System.IO.TextWriter to output the results to in the SPARQL Results XML output format.
⊟ Remarks
This method can also be called through Query.Run(SemWeb.SelectableSource, System.IO.TextWriter).⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Describe Method
Executes a DESCRIBE query on the given data source and sends the constructed statements to a StatementSink.
⊟ Parameters
- source
- The data source to query.
- sink
- The SemWeb.StatementSink to send the constructed statements to.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Describe Method
Executes a DESCRIBE query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.
⊟ Parameters
- source
- The data source to query.
- output
- The System.IO.TextWriter to output the results to in the SPARQL Results XML output format.
⊟ Remarks
This method can also be called through Query.Run(SemWeb.SelectableSource, System.IO.TextWriter).⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ GetQueryPrefixes Method
Gets a NamespaceManager containing all of the PREFIX definitions used in the query.
public SemWeb.NamespaceManager GetQueryPrefixes ()⊟ Returns
A NamespaceManager.⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Select Method
Executes a SELECT query on the given data source and sends the resulting variable bindings to a QueryResultSink.
⊟ Parameters
- source
- The data source to query.
- sink
- The SemWeb.Query.QueryResultSink to send the resulting variable bindings to.
⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Select Method
Executes a SELECT query on the given data source and outputs the result of the query in the SPARQL results format to a TextWriter.
⊟ Parameters
- source
- The data source to query.
- output
- The System.IO.TextWriter to output the results to in the SPARQL Results XML output format.
⊟ Remarks
This method can also be called through Query.Run(SemWeb.SelectableSource, System.IO.TextWriter).⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0
⊟ Type Property
Gets the type of the query.
public SparqlEngine.QueryType Type { get; }⊟ Value
The type of the query: SELECT, DESCRIBE, CONSTRUCT, or ASK.⊟ Remarks
None.⊟ Requirements
Namespace: SemWeb.Query
Assembly: SemWeb.Sparql (in SemWeb.Sparql.dll)
Assembly Versions: 0.0.0.0