LDPath (fka RDF Path) follows a syntax similar to XPath that can be used for selecting the values of properties. It has originally been developed for configuring the semantic search component of the Linked Media Framework, but has been moved out into a separate, generic module. It still contains some syntactical constructs that are only relevant for configuring semantic search; these are marked explicitly below.

Path Selectors

The path language supports a number of path selectors that start at the current "context node" and return a collection of nodes when applied. The following is a short overview over the different selectors, detailed documentation follows below:

Property Selections (URI or prefix:local): select the values of a property

Reverse Property Selections (^URI or ^prefix:local)

Wildcard Selections (*): select the values of all properties

Self Selector (.): select the current context node

Path Traversal (/): follow a path of selectors recursively

Unions (|): join the results of two selections in one collection

Intersections (&): build the intersection of the results of two selections

Recursive Selections ((PATH)+)

Tests ([...]): filter the collection based on test criteria

Language Test (@language): only literals of a certain language

Type Test (^^xsdtype): only literals of a certain type

Path Value Test (is): only resources with a subpath yielding a given value

Path Existance Test (PATH): only resources where a subpath yields some value

Functions (f(...)): apply a function on the values of the selections passed as argument

Property Selections

A path definition selecting the value of a property. Either a URI enclosed in <> or a namespace prefix and a local name separated by ":"

<URI> | PREFIX:LOCAL

Example:

Select the foaf:name property using namespace prefix and local name:

title = foaf:name :: xsd:string ;

Select the foaf:name property using the fully qualified URI

title = <http://xmlns.com/foaf/0.1/name> :: xsd:string;

Reverse Property Selections

This is the reverse/inverse operation of the normal Property Selection.

Select all nodes connected to the current node via an incoming link, aka. go the specified link "backwards":

^<URI>

Example:Get the names of all persons that link the current person as foaf:knows:

friends = ^foaf:knows / foaf:name :: xsd:string;

Note, however, that this kind of navigation is not completely supported over the Linked Data Cloud. While it might be against the ethos of RDF, Linked Data restricts these principles. In most cases it is not possible to know the incoming links from external datasets to a resource.

Wildcard Selections

Wildcard selections allow to select the values of all properties of a node. They are expressed by a "*":

*

Example:

Select all properties of the resource:

all = * :: xsd:string ;

Path Traversal

Traverse a path by following several edges in the RDF graph. Each step is separated by a "/".

PATH / PATH

Where PATH is an arbitrary path selector (e.g. a property selection or test)

Example:

Select the names of all friends:

friend = foaf:knows/foaf:name :: xsd:string;

Unions

Several alternative paths can be merged by using a union "|" between path elements

PATH | PATH

Where PATH is an arbitrary path selector.

Example:

Select the labels or names of all friends:

friend = foaf:knows/foaf:name | foaf:knows/rdfs:label :: xsd:string;

Intersections

The intersection of several paths can be computed by using an intersection "&" between path elements

PATH & PATH

Where PATH is an arbitrary path selector.

Example:

Select values that are both defined for foaf:interest and foaf:topic_interest:

topic_interests = foaf:interest & foaf:topic_interest :: xsd:anyURI;

Recursive Selections

Recurseive selection will apply an selectore recursively. The recursion can be limited with lower and upper bounds.

Groupings

Path expressions can be grouped to change precedence or to improve readability by including them in braces:

( PATH )

where PATH is an arbitrary path selector.

Example:

Select the labes or names of friends:

friend = foaf:knows/(foaf:name | rdfs:label) :: xsd:string ;

Value Testing

The values of selections can be tested and filtered by adding test conditions in square brackets [] after a path selection:

PATH [TEST]

where PATH is an arbitrary path selector and TEST is a test condition (see below).

Literal Language Test

Literal language tests allow to select literal values of only the specified language. They can be expressed by '@' followed by the ISO language tag or the special value none to select literals without language definition.

@LANGUAGE

where LANGUAGE is the ISO language tag or the value "none".

Example:

Select labels with either German language or no defined language:

title = rdfs:label[@de] | rdfs:label[@none] :: xsd:string ;

Literal Type Test

Literal type tests allow to select only literals of a specified type, e.g. to ensure that only decimal values are indexed:

Builtin: Resource Content

In some cases you will want to retrieve the human-readable content (e.g. in HTML) that is associated with a resource, e.g. a website. The RDF Path language has a builtin function to achieve this goal:

content = fn:content(.) :: lmf:text_en ;

would retrieve the content of the current resource and index it as English text. Arbitrary paths can be used, so this function can also be used to retrieve the content of resource selected by more complex path selections:

homepage_content = fn:content(foaf:homepage) :: lmf:text_en ;

would retrieve the homepage of a foaf:Person and index it as English text.

Index Types (Search Indexing only)

All XML Schema built-in datatypes (http://www.w3.org/TR/xmlschema-2/) are supported as field types in the SOLR index. In particular, the following field types are frequently used:

xsd:anyURI - URI values, indexed without further processing like tokenization

xsd:string - String values, indexed without further processing like tokenization