XQuery/Example Sequencer

The code examples used in the XQuery /SQL comparison are coded in an XML file. The WikiBook page redundantly has the code pasted into the page but an alternative is to provide an application to generate the whole page together with the executed examples from the XML script.

Here is a sample of the XML script:

 List the name of each employee together with the name of their manager. select e.ename, m.ename from emp e, emp m where e.mgr = m.empno ; <![CDATA[for $emp in //Emp let $manager := //Emp[EmpNo = $emp/MgrNo] return  {$emp/Ename} {string($manager/Ename)}  ]]> The SQL Join has missed Employee King who has no manager, 

To allow the queries to be executed in a selected order, a lesson defines a sequence of queries:

 Test Lesson 1</Name> <Step queryid="32"/> <Step queryid="33"/> <Step queryid="31"/> <Step queryid="21a"/> <Step queryid="20"/> </Lesson>

The user can step through the examples in the lesson :

Test Lesson

Implementation
Two scripts form the core of this application, one to list the queries in a lesson, the other to execute the query code, both SQL and XQuery and show the results. ....