-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Open Question: session.xq migration
The legacy module migration has removed most modules/*.xq files, but session.xq is fundamentally different from the others and warrants discussion before migrating.
Current Architecture
session.xq is not a standalone endpoint — it's a view in eXist-db's URL-rewrite pipeline:
POST execute— controller sends the user's query toXQueryServletfor evaluation, then pipes the results as a request attribute tosession.xq, which stores them in the HTTP session and returns<result hits="N" elapsed="T"/>GET results/N— controller forwards tosession.xqwith anumparameter, which retrieves item N from the session and returns an HTML<div>with badges, copy buttons, and syntax highlighting
The frontend (eXide.js) expects:
- XML
<result>or<error>elements fromexecute - HTML fragments from
results/N, rendered directly into the DOM
API Replacement (already written)
modules/api/query.xqm already provides JSON equivalents:
POST /api/query— executes viautil:eval(), returns{ id, count, elapsed, items[] }GET /api/query/{id}/results?start=N&count=M— paginated JSON result retrieval
Key Differences & Concerns
| Aspect | session.xq (current) | query.xqm (API) |
|---|---|---|
| Execution | XQueryServlet (full context) | util:eval() |
| Error handling | XQueryServlet <error> elements, including null-description edge case |
try/catch with structured JSON errors |
| Result rendering | Server-side HTML (<div> with badges, match highlights) |
Client-side rendering from JSON strings |
| Match highlights | util:expand($item, "highlight-matches=both") |
Not yet implemented |
| Serialization modes | html5, xhtml, xhtml5, json, text, xml, adaptive, microxml — non-XML modes bypass session and render directly in iframe | All modes serialize to JSON string items |
| Module load path | Set via xquery.module-load-path request attribute in controller |
Passed as base parameter to util:eval() |
Questions
-
XQueryServlet vs util:eval() — Are there meaningful behavioral differences? XQueryServlet sets up a full execution context via the URL rewrite chain. Does
util:eval()with abaseparameter provide equivalent module resolution? -
Match highlighting —
util:expand()withhighlight-matches=bothis used insession.xqfor full-text search result highlighting. Should this be added toquery.xqm, or handled client-side? -
Non-XML serialization modes — Currently, non-standard output modes (html5, xhtml, etc.) bypass the session entirely and render raw output in an iframe. The API approach serializes everything to JSON strings. Is there a use case where raw iframe rendering is important?
-
Migration scope — Moving to the API requires rewriting the frontend result rendering (currently receives HTML, would need to build DOM from JSON). Is this worth doing now, or should
session.xqremain as-is until a larger editor refactor?
Related
- PR Manual UI review: consistency and functionality fixes #12 (ui-review-polish) — current migration work
- Tracking issue eXide overhaul: PR chain #15 — eXide overhaul PR chain