Continuing with my test.xqm experiments… I have copied Saxon jar into WEB-INF/lib/ so xslt:transform is using Saxon.
I have the following functions declared: declare %rest:path("test/xqdoc.xml") %output:method('xml') function test:doc() { inspect:xqdoc( $test:module_name ) }; declare %rest:path('test/xdoc') %output:method('html’) (: I’ve tried various values for method and html-version here ! :) %output:html-version('5.0') function test:htmldoc() { (: WTF? :) xslt:transform( test:doc(),'static/xsl/html-module.xsl', map { 'source' : 'test.xqm' }) }; Where html-module.xsl initially was: https://github.com/xquery/xquerydoc/blob/master/src/lib/html-module.xsl <https://github.com/xquery/xquerydoc/blob/master/src/lib/html-module.xsl> Accessing /basex/test/xdoc returns error message: Stopped at /usr/local/tomcat/webapps/basex/test.xqm, 41/20: [FODC0002] "" (Line 69): The entity "nbsp" was referenced, but not declared. Which was initially very puzzling, as I could not find nbsp in either my test.xqm, html-module.xsl, or inspect:xsdoc() output. Turns out, even though it was encoded as " ” in html-module.xsl, Saxon was encoding it as “ ” on output of the transform. Initially, I wasn’t sure if Saxon or BaseX was doing the serialization. I guess it seems to be both. Original output method for that stylesheet is: <xsl:output method="html" indent="yes" encoding="UTF-8"/> And changing output:method on the function to xhtml or html doesn’t have any effect on results. Changing output method on the stylesheet to xhtml causes Saxon to serialized it as “ ” instead of “ ” , and the serialization method on the basex RESTXQ function doesn’t seem to give an errors with any output methods. 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. I don’t suppose there is a way to short circuit the parsing of the xslt:transform function output and just output the results directly (?) I tried xslt:transform-text() but it escapes all of the element tags. Or a way to get it to parse the results of that transform function as html ? Clearly changing the stylesheet is the easy solution for this test file, but for some of my other real cases, I may be trying to repurpose stylesheets that will be used in different contexts: within BaseX and outside of that context, so keeping different versions of the stylesheets is going to be annoying. I suppose I could read in the stylesheets and modify the xml:output line in XQuery or XSLT before using it within BaseX. — Steve M.
smime.p7s
Description: S/MIME cryptographic signature