Skip to content

Path Expression

A structured-data query expression that composes navigation steps to select nodes or values under a language's tree or graph semantics.

Version
v1 · 2026-10-17 · History
Domain-specific #
14245
Domain group
Applied Sciences & Engineering
Origin domain
Computer Science & Software Engineering
Subdomains
XML Query, Graph Query → Computer Science & Software Engineering
Aliases
Navigational Path Expression, Query Path Expression

Core Idea

A path expression tells a query how to reach data through named or typed steps. The steps operate on a structured data model, such as an XML tree or an RDF graph. A context node or subject/object positions give the language a place to interpret the path; those positions can include variables discovered during query matching. The expression describes a route pattern, while the actual data determines what nodes or values match it.[1][2]

XPath 3.1 uses slash-separated tree steps. SPARQL 1.1 uses property paths between graph endpoints. Both compose relations, but their result, ordering, duplicate, and error rules belong to their own languages. A fixed known root, a filter, and repetition are not required in every path expression.[1][2]

How would you explain it like I'm…

Step-by-Step Finding Directions

A path expression is like directions for finding something: "Start here, go to the kitchen, then open the cupboard, then find the cups." Each step tells you where to go next from where you are. A computer follows those steps through its information to find what you asked for.

Step-by-Step Data Directions

Computers store information connected together, like a family tree or a web of friends. A path expression is a set of step-by-step directions for finding information by following those connections. For example: "start here, go to the chapters, then go to their paragraphs." Each step starts where the last step ended. The directions describe a pattern of route, so you can use them again and again, even when you don't know ahead of time what you'll find.

Step-Composed Query Navigation

A path expression is a piece of query syntax that describes how to reach data by following a sequence of relationships in a structured data model. Evaluation starts from a context or set of positions; each step names a relationship to follow, and the results of one step become the starting points for the next. Because the steps describe a pattern of routes rather than naming specific results, the expression can be reused. In XPath, used for XML trees, "child::div1/child::para" starts at the current node, goes to its div1 children, then to their para children. In SPARQL, used for RDF graphs, "?x foaf:knows/foaf:name ?name" links a person to the names of people they know, with the variables filled in by matching. The data models and result rules differ, but both compose steps the same way.

 

A path expression is query syntax that specifies how to reach data through a sequence of navigable relations in a structured data model. The language supplies a context or endpoint positions, each step names a relation to traverse, and evaluation yields the matching nodes or values. Its identity is step composition: the endpoints of one step are the positions at which the next step applies. Because the steps describe a route pattern rather than naming a prior query's result, the expression is reusable. XPath 3.1 treats paths as its characteristic way of addressing nodes in an XML tree, so child::div1/child::para selects para children of div1 children of the context node. SPARQL 1.1 property paths relate endpoint positions in an RDF graph, as in ?x foaf:knows/foaf:name ?name, where the variables are bound by matching rather than known in advance. Roots, result rules, and operator inventories differ between languages; none is part of the common identity.

Scope of Application

In XML querying, child::div1/child::para selects para children of div1 children of the current context node. XPath can also begin a path at a document root, and it supports predicates within steps. When its slash operator returns nodes, XPath removes duplicate nodes and returns them in document order; other result types use different handling.[1]

In RDF querying, SPARQL's ?x foaf:knows/foaf:name ?name joins a knows predicate step to a name step. Its endpoint positions can be variables, and the graph can be cyclic. SPARQL also offers inverse, alternative, and repeated property paths, but a simple two-step sequence needs none of them. XPath's node-order guarantee is not a general SPARQL guarantee.[2]

Clarity

Keep the written expression separate from the matched result. The expression fixes which relations to follow and in what order; the data may supply zero, one, or many matches. If a query returns an unexpected value, check the starting context or endpoint positions, the step order, and the host language's evaluation rules before assuming that the data contains the intended route.[1][2]

The distinction also separates this entry from the live Prime Path. A Prime Path is one committed edge sequence. A path expression is a formal query construction that may match several routes or none. Its accepted DAG parent is Prime Relation as an internal semantic constituent: each navigation step needs a rule specifying which positions are related. The expression itself is not a Relation.

Manages Complexity

Composing steps gives a compact way to state a multi-relation query. SPARQL's specification translates :p/:q into two predicate edges linked through an intermediate variable; the slash form does not require the query writer to name that intermediate position. XPath's slash form similarly makes a tree route readable as a sequence of steps.[1][2]

The compact form is easiest to debug when it is expanded back into the language's actual semantics. XPath has focus, node-order, duplicate, non-node, and error rules at the slash operator. SPARQL has graph-pattern and property-path rules. Shared path vocabulary does not make those detailed rules identical.[1][2]

Abstract Reasoning

The useful structural move is to compose relations in order. The first step identifies possible intermediate positions; the next step applies at those positions. Swapping steps usually changes the query. A one-step path is still a path expression, though composition becomes visible when there are two or more steps.[1][2]

This gives a simple counterfactual test: remove or change one step and ask which endpoints can still be selected. The test concerns the expression's meaning under a data model. It does not require a search frontier, a human navigator, or a previously realized path.

Knowledge Transfer

The same checklist helps read paths in different structured query languages: identify the data model, the context or endpoint positions, the ordered step relations, and the result rules. That transfers from XML tree queries to RDF graph queries while keeping each language's details in place.[1][2]

The transfer stops at those shared roles. SPARQL's variable and cycle behavior is not an XPath rule, and XPath's document ordering is not a SPARQL promise. A road itinerary or an observed citation chain may be a path, but it is not a path expression in this query-language sense merely because it has ordered links.

Example

XPath's child::div1/child::para uses an XML tree (data model), a current node (context), the div1 then para child steps (ordered relations), and XPath's node-selection rules (evaluation). SPARQL's ?x foaf:knows/foaf:name ?name uses an RDF graph, two endpoint variable positions, the knows then name predicate steps, and SPARQL path-pattern matching. The cases have different data structures and result rules but the same step-composition roles.[1][2]

Relationships to Other Abstractions

Local relationship map for Path ExpressionParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.Path ExpressionDOMAINPrime abstraction: Relation — includesRelationPRIME

Current abstraction Path Expression Domain-specific

Parents (1) — outgoing typed relations

  • Path Expression includes Relation Prime

    A path expression contains one or more language-defined navigation-step relations as identity-bearing semantic constituents.

Hierarchy path (1) — routes to 1 parentless root

Neighborhood in Abstraction Space

Path Expression sits in a sparse region of the domain-specific corpus (93rd percentile for distinctiveness): few abstractions share its structure, so a faithful description tends to retrieve it precisely.

Family — Unclustered & Miscellaneous (3155 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14

Not to Be Confused With

Prime Path is an already specified edge sequence, and Network Traversal is a procedure with a frontier and visit policy. Query Rewriting changes a query into an equivalent form; a path expression is a form that can be evaluated without being rewritten. The phrase also has a separate process-synchronization meaning in concurrency research; that homonym is outside this entry.[3]

The accepted DAG edge is domain_specific:path_expression → prime:relation, typed composition/part_of with the relation step inside the expression's meaning. It does not claim that all XPath slash operations are pure associative binary relation composition.[1]

References

[1] W3C XML Query Working Group and XSLT Working Group, XML Path Language (XPath) 3.1, W3C Recommendation, 21 March 2017, §§3.3–3.3.5, especially §§3.3.1–3.3.1.1. https://www.w3.org/TR/2017/REC-xpath-31-20170321/ registry ↩a ↩b ↩c ↩d ↩e ↩f ↩g ↩h ↩i ↩j

[2] W3C SPARQL Working Group, SPARQL 1.1 Query Language, W3C Recommendation, 21 March 2013, §§9.1–9.3 and 18.2.2.3–18.2.2.4. https://www.w3.org/TR/2013/REC-sparql11-query-20130321/ registry ↩a ↩b ↩c ↩d ↩e ↩f ↩g ↩h ↩i

[3] Roy Harold Campbell, Path Expressions, A Technique for Specifying Process Synchronization, PhD thesis, Newcastle University, 1976. The repository prints a colon after “Expressions”; comma transcribed here for citation binding. Institutional repository metadata and abstract consulted for the homonym only; full thesis not inspected. https://theses.ncl.ac.uk/jspui/handle/10443/1973 registry ↩