Hi Steve!
I take from these results that the output from Saxon xslt:transform is serialized according to the stylesheet, and then parsed again by BaseX as xml on the way to being serialized again on output from the function, and the error is coming from that implicit parse.
The communication between BaseX (and others) and Saxon is:
* BaseX passes XML (serailizes it or passes some object which Saxon uses to read the document into its own internal representation)
* Saxon genereates an output according what you configure using xslt:output
* BaseX has to read and interpret that output to process it any further.
The last step means that Saxon has to generate something that BaseX can consume and that is XML most of the time. method html on purpose uses some constructs that are not wellformed XML and uses entitiies always defined in HTML to be more compatible with some now outdated browsers.
In the end because you run Saxon to transform your XML and then (possibly) process it using XQuery again to generate output BaseX is the tool that has to be told what the output should look like. Saxon has to be used in a way that BaseX unterstands.
So in the end you will most of the times end up with having to tell Saxon to produce XML or XHTML. You may be able to do this using two XSL stylesheets that only contain xslt:output and import the actual stylesheet.
I tried xslt:transform-text() but it escapes all of the element tags.
I didn't try that but as I understand it xslt:transform-text() should give you some unparsed text that BaseX can't process any further but if output by BaseX (using a text method from BaseX standpoint probably) should be the short circuit you are looking for.
Best regards
Omar