Hi Steve,
If you want Saxon to do the HTML serialization, you could proceed as follows:
declare %rest:path('test/xdoc') %output:media-type("text/html") function test:htmldoc() { xslt:transform-text('your.doc', 'your.xsl') };
I used xslt:transform-text to retrieve the result as string (because it won’t be valid XML anymore due to the HTML representation), and I specified text/html as media-type (this way, your output won’t be serialized as HTML again).
I couldn’t try your example, so you may need to tweak it a little further.
Best, Christian