hasFeature continued

I've been able to do a little testing with Microsoft's implementation, unfortunately testing Netscape will have to come later.

Trying to use hasFeature with an "unspecified" version, runs into a catch 22.

MSXML's implementation is defined in terms of a COM BSTR.  Accessed from C++, you can pass in NULL as the value for the BSTR.  However, it is not possible to make a call from Visual Basic or JScript
that calls the COM interface with a BSTR value of NULL.

The MSXML implementation will return true for impl.hasFeature("XML",null) (in languages that can do that) but will return false for empty strings.

So from JScript or VB:

impl.hasFeature("XML","1.0")  -  true
impl.hasFeature("XML","")     -  
    false, no special significance given to empty string
impl.hasFeature("XML",undefined) -
    exception raised before call since 
    null or undefined cannot be coersced to a string
impl.hasFeature("XML") -
    wrong number of arguments

The only pattern that would work across all languages is a empty string.

For languages where null is an allowable value for String (for example, Java but not VB or ECMAScript) then defining the behavior to be identical to empty string would be helpful, but nearly
impossible to write succinctly.


This is the version number of the feature to test. In Level 2, the string can be either "2.0" or "1.0". If the version is an empty string (or a null string when the value space of the string type
contains such a value), supporting any version of the feature causes the method to return true. 

Received on Thursday, 12 July 2001 15:30:17 UTC