Subject: RE: [xsl] Getting non-existing, but supplied, parameters From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 12 Sep 2006 23:31:35 +0100 |
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.online@xxxxxxxxx] > Sent: 12 September 2006 22:52 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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>	</xsl:text> > <xsl:if test="position() mod 2"> > <xsl:text>
</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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Getting non-existing, but sup, Abel Braaksma | Thread | Re: [xsl] Getting non-existing, but, Abel Braaksma |
Re: [xsl] Numbering 1st 2nd 3rd ..., Spencer Tickner | Date | Re: [xsl] Getting non-existing, but, Abel Braaksma |
Month |