/metaschema:metapath-expressionsfrom metaschema
Covers Metapath expression syntax for constraints, queries, and traversals in Metaschema, including path expressions, predicates, operators, and functions based on XPath 3.1.
Ships in metaschema. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Metapath is based on XPath 3.1, adapted for Metaschema's data model. This skill covers the expression language used in Metaschema constraints and queries.
| Expression | Description |
|---|---|
. | Current node (context item) |
.. | Parent node |
./child | Child named "child" |
./child/grandchild | Nested navigation |
.//descendant | Any descendant named "descendant" |
@flag | Flag (attribute) named "flag" |
//root | From document root |
| Axis | Description | Example |
|---|---|---|
child:: | Direct children (default) | child::name = ./name |
parent:: | Parent node | parent::* |
ancestor:: | All ancestors | ancestor::catalog |
ancestor-or-self:: | Ancestors plus current | ancestor-or-self::* |
descendant:: | All descendants | descendant::item |
descendant-or-self:: | Descendants plus current | descendant-or-self::* = .// |
self:: | Current node | self::node() |
preceding-sibling:: | Preceding siblings | preceding-sibling::item |
following-sibling:: | Following siblings | following-sibling::item |
| Pattern | Description |
|---|---|
* | Any element |
@* | Any flag (attribute) |
node() | Any node |
Filter nodes using conditions in brackets:
./item[@status = 'active']
./user[position() = 1]
./entry[starts-with(@id, 'X-')]
./control[exists(./part)]
./param[@id][not(@class = 'hidden')]
./item[1] # First item
./item[last()] # Last item
./item[position() > 1] # All but first
./item[position() mod 2 = 0] # Even positions
| Operator | Description | Note |
|---|---|---|
=, != | General comparison | Compares sequences |
eq, ne | Value equality | Single values only |
<, >, <=, >= | General comparison | Compares sequences |
lt, gt, le, ge | Value comparison | Single values only |
General vs Value Comparison:
=, <, etc.): Works with sequences, returns true if any pair matcheseq, lt, etc.): Requires single values, raises error on sequences| Operator | Description |
|---|---|
and | Logical AND |
or | Logical OR |
not() | Logical NOT (function) |
| Operator | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
div | Division |
idiv | Integer division |
mod | Modulo |
| Operator | Description |
|---|---|
|| | String concatenation |
| Operator | Description |
|---|---|
, | Sequence construction |
| | Sequence union |
to | Range (e.g., 1 to 5) |
Reference variables defined with let:
$variable-name
$parent/child
count($items)
$config/@value
Note on function variants: Many functions have multiple signatures with different argument counts. Optional parameters are shown with ?. For the authoritative list of all function signatures, see the source code in:
core/src/main/java/dev/metaschema/core/metapath/function/library/
| Function | Description |
|---|---|
string(item?) | Convert to string |
string-length(string?) | Length of string |
normalize-space(string?) | Normalize whitespace |
upper-case(string) | Convert to uppercase |
lower-case(string) | Convert to lowercase |
concat(str1, str2, ...) | Concatenate strings |
string-join(strings, sep?) | Join with separator |
substring(str, start, len?) | Extract substring |
substring-before(str, search) | Text before match |
substring-after(str, search) | Text after match |
contains(str, search) | Contains substring |
starts-with(str, prefix) | Starts with prefix |
ends-with(str, suffix) | Ends with suffix |
matches(str, regex) | Regex match |
tokenize(str, pattern?) | Split string |
compare(str1, str2) | Compare strings (-1, 0, 1) |
| Function | Description |
|---|---|
abs(num) | Absolute value |
ceiling(num) | Round up |
floor(num) | Round down |
round(num) | Round to nearest |
sum(nums) | Sum of sequence |
avg(nums) | Average of sequence |
min(items) | Minimum value |
max(items) | Maximum value |
| Function | Description |
|---|---|
boolean(item) | Convert to boolean |
true() | Boolean true |
false() | Boolean false |
not(bool) | Logical negation |
| Function | Description |
|---|---|
count(items) | Count of items |
empty(items) | True if empty |
exists(items) | True if not empty |
head(items) | First item |
tail(items) | All but first |
reverse(items) | Reverse order |
distinct-values(items) | Remove duplicates |
index-of(seq, search) | Find positions |
insert-before(seq, pos, items) | Insert items |
remove(seq, pos) | Remove at position |
one-or-more(items) | Assert at least one |
zero-or-one(items) | Assert zero or one |
exactly-one(items) | Assert exactly one |
| Function | Description |
|---|---|
name(node?) | Qualified name |
local-name(node?) | Local name |
namespace-uri(node?) | Namespace URI |
root(node?) | Document root |
path(node?) | Path expression |
has-children(node?) | Has child nodes |
innermost(nodes) | Remove ancestors |
outermost(nodes) | Remove descendants |
data(items) | Atomize values |
| Function | Description |
|---|---|
current-date() | Current date |
current-time() | Current time |
current-dateTime() | Current date-time |
year-from-date(date) | Extract year |
month-from-date(date) | Extract month |
day-from-date(date) | Extract day |
year-from-dateTime(dt) | Extract year |
month-from-dateTime(dt) | Extract month |
day-from-dateTime(dt) | Extract day |
hours-from-dateTime(dt) | Extract hours |
minutes-from-dateTime(dt) | Extract minutes |
seconds-from-dateTime(dt) | Extract seconds |
timezone-from-date(date) | Extract timezone |
timezone-from-time(time) | Extract timezone |
timezone-from-dateTime(dt) | Extract timezone |
hours-from-time(time) | Extract hours |
minutes-from-time(time) | Extract minutes |
seconds-from-time(time) | Extract seconds |
implicit-timezone() | Default timezone |
adjust-date-to-timezone(date, tz?) | Adjust timezone |
adjust-time-to-timezone(time, tz?) | Adjust timezone |
adjust-dateTime-to-timezone(dt, tz?) | Adjust timezone |
dateTime(date, time) | Combine date and time |
| Function | Description |
|---|---|
years-from-duration(dur) | Extract years |
months-from-duration(dur) | Extract months |
days-from-duration(dur) | Extract days |
hours-from-duration(dur) | Extract hours |
minutes-from-duration(dur) | Extract minutes |
seconds-from-duration(dur) | Extract seconds |
| Function | Description |
|---|---|
position() | Current position (1-based) |
last() | Total count in context |
static-base-uri() | Base URI from static context |
base-uri(node?) | Base URI of node |
document-uri(node?) | Document URI |
| Function | Description |
|---|---|
doc(uri) | Load document |
doc-available(uri) | Check if loadable |
resolve-uri(relative, base?) | Resolve URI |
| Function | Description |
|---|---|
array:size(array) | Array length |
array:get(array, pos) | Get element |
array:head(array) | First element |
array:tail(array) | All but first |
array:reverse(array) | Reverse order |
array:append(array, item) | Append item |
array:join(arrays) | Concatenate arrays |
array:flatten(array) | Flatten nested arrays |
array:insert-before(array, pos, item) | Insert at position |
array:remove(array, pos) | Remove at position |
array:put(array, pos, item) | Replace at position |
array:subarray(array, start, len?) | Extract subarray |
| Function | Description |
|---|---|
map:size(map) | Number of entries |
map:keys(map) | All keys |
map:contains(map, key) | Has key |
map:get(map, key) | Get value |
map:put(map, key, value) | Add/update entry |
map:remove(map, keys) | Remove entries |
map:entry(key, value) | Create entry |
map:merge(maps) | Merge maps |
map:find(item, key) | Deep find |
map:for-each(map, fn) | Transform entries |
| Function | Description |
|---|---|
function-name(fn) | Get function name |
function-arity(fn) | Get parameter count |
function-lookup(name, arity) | Look up function |
| Function | Description |
|---|---|
deep-equal(item1, item2) | Deep comparison |
| Function | Description |
|---|---|
mp:base64-decode-text(base64Binary) | Decode base64 to string |
mp:base64-encode-text(string) | Encode string to base64 |
mp:recurse-depth(recursePath) | Recursive traversal from focus |
mp:recurse-depth(context, recursePath) | Recursive traversal from context |
Non-empty required value:
exists(.) and string-length(normalize-space(.)) > 0
Date range validation:
. <= ../end-date
Mutually exclusive fields:
not(exists(./option-a) and exists(./option-b))
At least one of:
exists(./email) or exists(./phone)
Count validation:
count(./item) >= 1 and count(./item) <= 10
Pattern matching:
matches(., '^[A-Z]{2}-[0-9]{4}$')
Cross-reference validation:
. = ancestor::catalog//param/@id
Conditional validation:
not(exists(../end-date)) or . <= ../end-date
Find all descendants of a type:
.//control
Find siblings:
../item[@type = 'related']
Find ancestor with condition:
ancestor::group[@class = 'container']
Find by multiple criteria:
./param[@id][@class = 'public'][exists(./value)]
Metapath follows XPath 3.1 error semantics:
| Error | Cause |
|---|---|
| Type error | Wrong type for operation |
| Cardinality error | Wrong number of items for value comparison |
| Cast error | Invalid type conversion |
| Dynamic error | Runtime evaluation failure |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
4 skills in this plugin
/metaschema-basicsUse as an introduction to Metaschema concepts - provides overview and routes to detailed skills/metaschema-constraints-authoringUse when creating or modifying Metaschema constraints - covers all constraint types, inline vs external constraints, Metapath expressions, and validation patterns/metaschema-module-authoringUse when creating or modifying Metaschema modules - guides module structure, definitions, format-specific features, and best practices for both YAML and XML formatsnpx claudepluginhub metaschema-framework/claude-plugins --plugin metaschema