Taking up the pipeline idea, I rewote the fire application to use a sequence of XSLT transformations. XQuery now just glues them together.
This uses 3 XSLT scripts:
declare option exist:serialize "method=xhtml media-type=application/xhtml+xml omit-xml-declaration=no indent=yes doctype-public=-//W3C//DTD XHTML 1.0 Strict//EN doctype-system=http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"; let $xml := doc("http://elev.at/lift?xls=http://www.communities.gov.uk/documents/statistics/xls/1403043.xls") let $data := transform:transform( $xml , doc("/db/Wiki/graph2svg/xsl2fire.xsl") ,( )) let $graph := transform:transform( $data , doc("/db/Wiki/graph2svg/fires.xsl") , ()) let $svg := transform:transform( $graph , doc("/db/Wiki/graph2svg/xmsgr2svg.xsl") ,() ) return <html xmlns="http://www.w3.org/1999/xhtml" xmlns:svg="http://www.w3.org/2000/svg"> <head> <title>Fires in the UK</title> </head> <body> <h1>Fires in the UK</h1> {$svg} </body> </html>
The steps create intermediate documents - easier for testing than nesting the transformations.
My next task is to replace the XQuery script with an XProc pipeline.