Callimachus supports four ways of passing parameters to named queries: as wild parameters, relative pararmeters, lexical parameters, or expression parameters.

Wild parameters

Wild parameters use the SPARQL variable syntax with a prefix of '$', as shown in Example 1.

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?title {
  $doc a foaf:Document; dcterms:title ?title
}

Example 1: Named query that uses wild parameters

The value of the query parameters are any RDF term using the SPARQL term syntax. URIs are absolute or relative to the Named Query and wrapped in '<' and '>'. Literals maybe numeric or strings in double quotes and may include a language or datatype.

In Example 1, requests with the suffix ?results will return the title of all documents in the RDF store. This compares to requests with the suffix ?results&doc=%3Cdoc1%3E. These requests return document titles within the same namespace as the Named Query and a local part of "doc1".

Note: The %3C and %3E are percent encodings of '<' and '>'.

Relative parameters

Relative parameters must be bound and can only be a relative or absolute URI (i.e. not a literal value), as shown in Example 2.

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?title {
  <$doc> a foaf:Document; dcterms:title ?title
}

Example 2. Named query that uses relative parameters

In Example 2, requests with the suffix ?results will not return any results. However requests with the suffix ?results&doc=doc1 will retrieve the title of the <doc1> resource. The value of the query parameters are any relative or absolute URI (without angle brackets).

Lexical parameters

Lexical parameters must be bound and only be bound to literals, as shown in Example 3.

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?doc {
  ?doc a foaf:Document; dcterms:title "$title"@en
}

Example 3. Named query that uses lexical parameters

The datatype and language (if present) must be present in the Named Query itself and cannot be provided using lexical query parameters. As with relative parameters, a request using the suffix ?results will not return any results. However a request with the suffix ?results&title=Linking+Enterprise+Data will result in the document URI with an English title of "Linking enterprise Data"@en (if present in the RDF store). The value of the query parameters are any lexical value.

Expression parameters

Expression parameters are used to calculate the OFFSET and LIMIT for results, as shown in Example 4.

PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
PREFIX dcterms: <http://purl.org/dc/terms/>
SELECT ?title {
  ?doc a foaf:Document; dcterms:title ?title
} OFFSET ${ ($pageNumber - 1) * $pageSize } LIMIT ${ $pageSize }

Example 4. Named query that uses expression parameters

Unlike other parameters, expression parameters must only have exactly one value per request. Expression parameters may contain any SPARQL expression of other (non-expression) parameters within a '${' and '}'. In this example, a request with the suffix ?results&pageNumber=1&pageSize=30 will result in a SPARQL with an OFFSET 0 and LIMIT 30.

Expression parameters have no name and do not appear in the query parameter. However, the parameters within an expression must be present in the query parameter.