xsl-list
[Top] [All Lists]

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

2006-09-12 15:31:51
You might like to look at Andrew Welch's Kernow utility to see how it
tackles this. (I can't remember how it does, but I remember the discussion
about how it should).

https://sourceforge.net/projects/kernowforsaxon

There are two possible ways to do it: one is to analyze the source
stylesheet, the other is to call 

((Controller)transformer).getBindery().getGlobalParameterMap()

I think it's better to prompt the user for parameters that are actually
defined in the stylesheet, rather than trapping the fact that they supplied
unwanted parameters after the event. 

At present I don't think Saxon offers any interface that allows you access
to all the parameters that were supplied, as distinct from those that were
declared.

Michael Kay
http://www.saxonica.com/



-----Original Message-----
From: Abel Braaksma [mailto:abel(_dot_)online(_at_)xs4all(_dot_)nl] 
Sent: 12 September 2006 22:52
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Getting non-existing, but supplied, parameters

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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>