Skip to main content

Module sparql_path

Module sparql_path 

Source
Expand description

Parse a SPARQL 1.1 property path expression (the Path production, SPARQL 1.1 §18.2 grammar rules [88]-[94]) into the Path algebra.

This exists as its own small recursive-descent parser rather than reusing spargebra’s query parser: spargebra lowers a parsed SELECT ?s <path> ?o straight to algebra, and for “simple” paths (no alternation/Kleene forms) that lowering silently rewrites the path into a chain of joined triple patterns rather than keeping a PropertyPathExpression tree — there is no reliable way to recover an arbitrary Path from the result. The Path grammar production itself is small and has been stable since SPARQL 1.1, so parsing it directly is the more robust option.

Supported: sequence (/), alternation (|), inverse (^), the Kleene forms (*, +, ?), grouping (( … )), and the a keyword for rdf:type. Negated property sets (!…) have no equivalent in the Path algebra and are rejected with a clear error.

Functions§

parse_property_path
Parse a SPARQL 1.1 property path expression, resolving prefixed names (prefix:local) against shapes’ declared @prefixes and a against rdf:type. <absolute IRI> forms are also accepted.