Using named template instead of source document

Here should go questions about transforming XML with XSLT and FOP.
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Using named template instead of source document

Post by dsewell »

Using Saxon from the command line it is possible to use the -it name flag to run a named template instead of providing a source document. Is there any way to do this from inside oXygen?

More generally, is there any way to pass arbitrary command-line arguments to Saxon, or is the set of options in the Preferences page for Saxon all that is available?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi David,

If you use the default Saxon processor from oXygen then all the Saxon options are sepcified through the oXygen options.
You should be able however to define Saxon also as a custom processor (you need to specify a command line, see Options->Preferences -- XML -- XSLT-FO-XQuery -- Custom Engines) and there you should be able to specify any command line options you need.

Except from this initial template thing what are other options you would need to specify that are not in the oXygen preferences?

Best Regards,
George
George Cristian Bina
dsewell
Posts: 125
Joined: Mon Jun 09, 2003 6:02 pm
Location: Charlottesville, Virginia USA

Post by dsewell »

Except from this initial template thing what are other options you would need to specify that are not in the oXygen preferences?
That is the major one. If you add support for the -it template flag, it might be reasonable also to add support for -im mode as well.

Using the -i flags is similar to passing a parameter to a stylesheet. Could it be incorporated into the "Configure Transformation Scenario" dialogue?
george
Site Admin
Posts: 2095
Joined: Thu Jan 09, 2003 2:58 pm

Post by george »

Hi David,

Using -i flags is not in fact similar with passing parameters, because when you specify an initial template for instance then you should not specify an XML source for the transformation. But we will consider adding support in the transformation scenario for that.

I gave may suggestion to set up a custom XSLT processor to use initial mode a try. It worked ok, below you have the steps I took. I configured Saxon 8 to run a stylesheet starting with an initial template called main.

Go to Options->Preferences -- XML -- XML-FO-XQuery -- Custom Engines
Click on New and specify:
Engine type: XSLT
Name: Saxon8Bmain
Command line: java -jar lib/saxon8.jar -it main -o ${out} ${xsl}
Click Ok.

Create for test a stylesheet like below:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template name="main">
<result>test</result>
</xsl:template>
</xsl:stylesheet>
Configure a transformation scenario that has the following settings:
XML URL: ${currentFileURL}
(that means we set the stylesheet as input - we need any XML there as the XML will in fact not be used because the engine will start with an initial template and no XML)
XSL URL: ${currentFileURL}
Transformer: Saxon8Bmain

Then execute the transformation (here there is a small glitch in oXygen that will be solved - it shows an warning that the transformer is not for 2.0, it wrongly considers that custome engines are for 1.0, just click Yes in that warning dialog to continue).
You should be able to see the result:

Code: Select all


<?xml version="1.0" encoding="UTF-8"?><result>test</result>
Best Regards,
George
George Cristian Bina
Post Reply