[xsl] Getting non-existing, but supplied, parameters

Subject: [xsl] Getting non-existing, but supplied, parameters
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 12 Sep 2006 23:51:56 +0200
Dear List,

(Using XSLT 2.0)
For a project, where several XSLT's are being used with each having different parameters, the user, requesting the transformation, may set these parameters. Incidentally, a user may set the wrong names for the parameters (or the system may suggest the wrong names).


In any case, when the XSLT process starts, several parameters are set, but may not exist in the xslt file. Is anyone aware of a method to get these non-existing parameters, for instance, by using an extension? Does Saxon have a way of doing this? Any other processor?

This is useful for finding potential mishaps, typos and errors. Also, when adding new stylesheets, showing how the stylesheet was called, helps. But my end-users only have a way of using stylesheets and cannot access log files or anything. Suppose, naively, something exists like the following:

<!-- getting a sequence of ('paramName' 'paramValue' 'paramName' 'paramValue') -->
<xsl:variable name="supplied-parameters" select="saxon:getSuppliedParameters()" />
<xsl:for-each select="$supplied-parameters">
<xsl:value-of select="." />
<xsl:text>&#x09;</xsl:text>
<xsl:if test="position() mod 2">
<xsl:text>&#x0a;</xsl:text>
</xsl:if>
<xsl:for-each>


When called like this (saxon specific syntax, one commandline):
java -jar saxon8.jar -t -o output.xml input.xml param.xslt param1="10" param2="http://someurl"; param3="anyotherValue"


This would output something like:
param1   10
param2   http://someurl
param3   anyotherValue

Regardless of these parameters being defined or not in the stylesheet "param.xslt".

Btw, I am using Java to call my template. Perhaps I can choose to use a java class as an extension? But my main concern is: is this information still available once the XSLT is called (the process is started), or is it lost immediately, once the processor finds that the parameters do not exist?

Thanks in advance for any advice,

Kind regards,

Abel Braaksma
http://abelleba.metacarpus.com

Current Thread