Passing options to saxon through xslt:transform

Tuesday, 9 November 2021 · 4 messages
GS
Graydon Saunders9 Nov 2021 01:11 #
Hello -- Somewhat to my surprise I've got the large XSLT 3.0 transform to load, or at least not complain about includes. (Load the input as a db; load the stylesheet from the file system. Be extra-careful about constructing URIs.) Which raises the prospect that I'll actually be able to run this transform from BaseX, but I cannot figure out how to set a value for the initial template. This query:
let $source := <dummy></dummy>

let $template :=
<xsl:stylesheet version="3.0" xmlns:xsl='
http://www.w3.org/1999/XSL/Transform'>
  <xsl:template name="xsl:initial-template">
    <thingy>Hello, World!</thingy>
  </xsl:template>

  <xsl:template match="/">
    <fail>matched on root</fail>
  </xsl:template>
</xsl:stylesheet>
return xslt:transform($source,$template,map{'initial-template': '{ http://www.w3.org/1999/XSL/Transform}initial-template'}) returns <fail>matched on root</fail> Which isn't surprising; setting initial-template is a Saxon option, not a parameter. If I try return xslt:transform($source,$template,map{},map{'initial-template': '{ http://www.w3.org/1999/XSL/Transform}initial-template'}) I get [XPTY0004] Unknown option 'initial-template'. (same with 'it'.) Is there a way to set Saxon options with xslt:transform? Thanks! Graydon
BD
Bridger Dyson-Smith9 Nov 2021 02:07 #
Graydon, There's almost certainly a much nicer way to do this - eg the examples you've provided - but could another option be to build out a proc:execute() call? It wouldn't be nearly as elegant, and may cause additional processing in the output, but that way you would have full access to command line Saxon options and switches. Best, (and apologies for the water cooler suggestion!) Bridger
Quoted text · Graydon Saunders · 48 lines
On Mon, Nov 8, 2021, 6:11 PM Graydon Saunders <graydonish at gmail.com> wrote: > Hello -- > > Somewhat to my surprise I've got the large XSLT 3.0 transform to load, or > at least not complain about includes. (Load the input as a db; load the > stylesheet from the file system. Be extra-careful about constructing > URIs.) Which raises the prospect that I'll actually be able to run this > transform from BaseX, but I cannot figure out how to set a value for the > initial template. > > This query: > > let $source := <dummy></dummy> > > let $template := > <xsl:stylesheet version="3.0" xmlns:xsl=' > http://www.w3.org/1999/XSL/Transform'> > <xsl:template name="xsl:initial-template"> > <thingy>Hello, World!</thingy> > </xsl:template> > > <xsl:template match="/"> > <fail>matched on root</fail> > </xsl:template> > </xsl:stylesheet> > > return xslt:transform($source,$template,map{'initial-template': '{ > http://www.w3.org/1999/XSL/Transform}initial-template'}) > > returns > <fail>matched on root</fail> > > Which isn't surprising; setting initial-template is a Saxon option, not a > parameter. > > If I try > return xslt:transform($source,$template,map{},map{'initial-template': '{ > http://www.w3.org/1999/XSL/Transform}initial-template'}) > > I get [XPTY0004] Unknown option 'initial-template'. (same with 'it'.) > > Is there a way to set Saxon options with xslt:transform? > > Thanks! > Graydon > > >
G
Graydon9 Nov 2021 02:15 #
Quoted text · Bridger Dyson-Smith · 6 lines
On Mon, Nov 08, 2021 at 07:07:15PM -0500, Bridger Dyson-Smith scripsit: > There's almost certainly a much nicer way to do this - eg the examples > you've provided - but could another option be to build out a > `proc:execute()` call? It wouldn't be nearly as elegant, and may cause > additional processing in the output, but that way you would have full > access to command line Saxon options and switches.
I had no idea proc:execute() was even there. I'd been looking for a BXS equivalent. (Step one; read all the docs. Step two; somehow retain all the docs.)
Quoted text · Bridger Dyson-Smith · 1 line
> Best, (and apologies for the water cooler suggestion!)
An entirely helpful suggestion! If I can get the transform step to behave, I am pretty sure I can manage the whole multi-step build-and-test process from a hierarchy of BXS calls with common configuration and that makes me happy. (Or at least much happier than the alternatives!) Much appreciated!
-- Graydon Saunders | graydonish at gmail.com Þæs oferéode, ðisses swá mæg. -- Deor ("That passed, so may this.")
CG
Christian Grün9 Nov 2021 17:35 #
Quoted text · Graydon · 3 lines
> > Best, (and apologies for the water cooler suggestion!) > > An entirely helpful suggestion!
I completely agree! Currently, we don’t provide support for vendor-specific transformation options, and it’s perfectly viable to run Saxon as external process and convert the result string back to XML.

⚡Generated with XQuery