The Ask Statement

Last revised 4/13/2021. Contact us.

(See also Indirect Queries.)

The Ask Statement is a statement in the SADL grammar that is used to create a persistent query as part of a SADL model. The query can be executed against an inferred model created from the model containing the Ask Statement by the menu item Test Model.

The Ask Statement begins with the keyword Ask followed by a colon. This may be followed by a query in one of two forms.

  1. The query can be a quoted string containing a largely opaque query in a format supported natively by the reasoner/translator pair selected. For Jena-based reasoner/translator pairs, the supported syntax is SPARQL. The SWI-Prolog reasoner/translator pair supports either SPARQL or Prolog queries.
  2. The query can be written as an expression in the SADL grammar. The SADL grammar supports a subset of SPARQL and so can only be used for relatively simple queries. A query in SADL syntax is translated by the selected translator into a query supported by the selected reasoner.

Examples of Native SPARQL Queries


Examples of Queries in SADL Syntax


Named Queries

A query can be given a name by inserting a non-conflicting name after the Ask keyword and before the colon. The query can then be referenced elsewhere, and executed when testing the model, by referencing the query name after Ask: ("Ask followed by a colon"). For example, here is the definition of a named query.


In this model or in another SADL model which imports, directly or indirectly, the model defining the named query, one can use the query with this statement.