Skip to content

Latest commit

 

History

History

README.md

XQuery Examples

XQuery status

Read-only analytics over FundsXML with XQuery 3.1. Positions and assets are joined by the shared UniqueID (the standard FundsXML link). FundsXML 4.x has no XML namespace — queries use bare element names, so they work unchanged on the 4.2.9 / 4.1.0 / 4.0.0 samples.

Query Purpose Notable
aggregate-by-assettype.xq Exposure grouped by AssetType group by, grand-total reconciliation
top-holdings.xq N largest holdings, names resolved external var n (default 10)
fund-summary.xq Fund/doc overview + reconciliation block version-agnostic (4.0.0 has no Version)
look-through.xq Fund-of-funds look-through readiness flags SC (fund) positions + weights

Run (per stack)

Stack Entry point Status
Java (s9api, no JAXB) invocation/RunXQuery.java ✅ verified (via Maven Wrapper)
Python invocation/run_xquery.py standalone via repo venv (pip install -e .)
BaseX see below needs BaseX install

The Java runner is standalone & cross-platform via the committed Maven Wrapper (./mvnw, or mvnw.cmd on Windows), from the repo root. It serializes the result to stdout (redirect to capture):

M="./mvnw -q -pl XQuery_Examples/invocation compile exec:java"
SRC=FundsXML_Files/4.2.9/positions/Mixed-Fund_Positions.xml

# to stdout
$M -Dexec.args="XQuery_Examples/fund-summary.xq $SRC"

# external variable; redirect stdout to a file
$M -Dexec.args="XQuery_Examples/top-holdings.xq $SRC n=5" > top.xml

$M -Dexec.args="XQuery_Examples/aggregate-by-assettype.xq $SRC"

# BaseX (in-memory, binds the document and the external variable)
basex -i "$SRC" -bn=5 XQuery_Examples/top-holdings.xq

Note: Saxon's net.sf.saxon.Query takes external variables as plain name=value arguments — not -param: (that is the XSLT entry point) and not !name=value (that sets serialization properties).