Re: [xsl] msxml and removing parameters from a cached processor

Subject: Re: [xsl] msxml and removing parameters from a cached processor
From: "Nick Fitzsimons" <nick@xxxxxxxxxxxxxx>
Date: Fri, 24 Mar 2006 08:49:26 -0000 (GMT)
Rob,

IIRC, the problem is indicated by the words:

"...a value of Empty or Null"

Although MS's page claims to be an example in JScript, the values "Empty"
and "Null" are actually VBScript values, or more precisely VBScript names
for a kind of COM value, which have a special significance to COM
components like MSXML. JavaScript's "null" is a JavaScript value which is
not the same as a COM value, and therefore causes the type error you're
seeing.

I've got around this in the past by having a <script language="VBScript">
section containing a function which returned VB's "Nothing" value;
something like:

Function getVBNothing
   getVBNothing = Empty
End Function

(my VBS is a bit rusty so that might not be quite right, but you get the
idea).

You can call this function from JavaScript, and it will give you the value
you need to send in the addParam call.

Thus:

function clearParam(xslProcessor, paramName) {
   xslProcessor.addParam(paramName, getVBNothing());
}

Sorry I can't help any more at the moment, but I'm on the last day of an 8
month project and have lots of stuff to take care of (otherwise they'll
keep me here ;-). If I get a chance I might be able to find the code and
post it next week if that would help? You can find out more about all this
COM/JScript value clash at Eric Lippert's blog (he's the guy who wrote the
Microsoft scripting engines) if you search around a bit - google for
"Fabulous Adventures in Coding" to find him.

Antsnio: I believe that the stylesheet would the use any default value set
for the param, but as noted above I don't have time to test that theory
today. The question that occurs to me now is, what value goes through if
you use addParam with Nothing if the param hasn't previously had a value
added, and therefore doesn't have a value to be removed? Something for me
to experiment on...

Cheers,

Nick.

> Antsnio Mota wrote:
>> And then what happens? The optional default value="xxx" is assumed or
>> the parameter will be Empty or Null?
>
> Neither really work as described in the docs. Using null causes a fatal
> error. Using an empty string causes an empty string to set as the value
> (I am pretty sure that is what I am seeing...)
>
> -Rob
>
>>
>> On 23/03/06, Nick Fitzsimons <nick@xxxxxxxxxxxxxx> wrote:
>>>> Hi,
>>>>
>>>> Is there some way to remove parameters from a cached
>>>> 'new ActiveXObject( 'Msxml2.XSLTemplate.3.0' )' XSL processor in
>>>> JavaScript?
>>>>
>>> From the MSXML documentation for addParameter:
>>> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/xmlsdk/html/9ddcd728-2646-494a-8fa4-3b68e8c032b7.asp>
>>>
>>> "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."
>>>
>>> HTH,
>>>
>>> Nick.
>>> --
>>> Nick Fitzsimons
>>> http://www.nickfitz.co.uk/
>
>
-- 
Nick Fitzsimons
http://www.nickfitz.co.uk/

Current Thread