[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] XSLT in MSXML - removeParameter?


Subject: Re: [xsl] XSLT in MSXML - removeParameter?
From: "Nick Fitzsimons" <nick@xxxxxxxxxxxxxx>
Date: Wed, 25 Mar 2009 15:07:08 -0000 (GMT)

On Wed, March 25, 2009 2:33 am, Scott Trenda wrote:
> I'm developing a generic Javascript client-side XSLT library that works
> across IE's MSXML-based IXSLProcessor and the W3C XSLTProcessor model in
> the other browsers. I'm struggling to find the correct way to remove a
> previously added parameter in MSXML, as it seems that they don't provide a
> straightforward way of doing so.
<snip>
> The documentation on addParameter() shows this:
>
> objXSLProcessor.addParameter(baseName, parameter, namespaceURI);
> baseName: The name that will be used inside the style sheet to identify
> the parameter context.
> parameter: In most cases, a number, Boolean, string, IXMLDOMNodeList, or
> IXMLDOMNode. Passing in a single node will produce a node list that
> contains one node (shortcut). To remove a parameter previously added to
> the processor, provide a value of Empty or Null instead. This acts as a
> signal to the processor to remove any previously added parameter of the
> same name.
> namespaceURI (optional): An optional namespace.
>
> Now, this looked promising, until I tried it:
> myProc.addParameter("myParam", null);
> This threw a "Type mismatch" error in IE. The same happened when I tried
> myProc.addParameter("myParam"), myProc.addParameter("myParam", undefined)
> and myProc.addParameter("myParam", null, ""). I tried
> myProc.addParameter("myParam"), but it threw a "Wrong number of arguments
> or invalid property assignment" error instead. If I try to remove the
> parameter with myProc.addParameter("myParam", ""), then it overwrites the
> default value in my stylesheet, like <xsl:param name="myParam"
> select="'defaultVal'" />.
>

I believe the problem you have is that a JavaScript "null" is not the same
thing as a VB "Nothing" or a C++ "Null". This is down to the way
JavaScript was implemented as a COM component, and the fact that its types
and the values thereof (including null) don't always map directly to
similar types and values in "native" COM components, such as MSXML.

Martin Honnen has already given you some useful information. Just to add
to that, I have a vague memory of being able to work around this by
calling out to a VBScript procedure; my VBScript is extremely rusty, but
it would be something like:

<script language="VBScript">

sub resetXsltParameter(myProc, parameterName)
    myProc.addParameter(parameterName, Nothing)
end sub

</script>

This procedure can then be called from JavaScript as if it were a global
function:

resetXsltParameter(myProc, "myParam");

(Of course you can include the VBScript in an external file rather than
directly in the page, and hide it from non-IE browsers using conditional
comments; but those implementation details are out of scope for this list
so I won't go into them.)

HTH,

Nick.
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/


Current Thread
Keywords