Hi Max,
Right, the xslt:transform expects the result to be a single, well-formed XML document. However, you can retrieve the transformation result as text and then apply fn:parse-xml-fragment on it:
fn:parse-xml-fragment( xslt:transform-text($DATA, $XSL) )
Hope this helps, Christian
On Mon, Jul 27, 2015 at 12:07 PM, Maximilian Gärber mgaerber@arcor.de wrote:
Hi,
calling the test-xsl function does not work (might be a bug). I think returning a document fragment from xsl is not forbidden (at least exist-db permits it).
The transform itself uses Saxon HE but this seems not related.
-- start xqm --
xquery version "3.0";
module namespace _= "http://foo.org/test"; import module namespace xslt = "http://basex.org/modules/xslt";
declare variable $_:DATA := <foo> <bar1></bar1> <bar2></bar2> </foo>;
declare variable $_:XSL := <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform%22%3E <xsl:output method="xhtml"/> <xsl:template match="/*/*"> <div>some div</div> </xsl:template> </xsl:stylesheet>;
declare %rest:GET %rest:path("test-xsl") function _:test-xsl(){
let $out := xslt:transform($_:DATA, $_:XSL) return $out
};
--- end xqm --
Message:
Stopped at test-xsl.xqm, 26/31:
[FODC0002] "" (Line 2): Markup im Dokument nach dem Root-Element muss ordnungsgemäß formatiert sein.
Regards, Max