Skip to main content
100%

This example of recursive descent in XQuery is adapted from Joe Wicentowski (https://gist.github.com/joewiz/2331558#file-typeswitch-skeleton-xq). It rather naively formats scenes from the Folger Library Shakespeare TEI editions for display in HTML. This example is intended for the demonstration of the concept, not actual use.

✓ Published0🌍 Public
CCliffordAnderson
Last edited Jan 2, 2014
Created on Jan 2, 2014

This example shows recursive descent in XQuery rendering scenes from a Folger Library Shakespeare TEI edition into HTML. It demonstrates how a typeswitch pattern matches distinct TEI elements—such as `tei:head`, `tei:w`, `tei:stage`, and `tei:speaker`—to produce formatted output like headings, stage directions, and speaker labels. The code relies on XQuery 3.0’s built-in `typeswitch` and function recursion, using `local:render` and `local:recurse` to traverse the XML tree. It serializes to XHTML via `exist:serialize`, pulling the source document from `/db/shakespeare/JC.xml` without external libraries.

AI-generated description

Similar vizzes