XPath Evaluation Types Are Not Easily Available Prior To Evaluation

The XPathResult interface defines the following constants:

  const unsigned short      ANY_TYPE                       = 0;
  const unsigned short      NUMBER_TYPE                    = 1;
  const unsigned short      STRING_TYPE                    = 2;
  const unsigned short      BOOLEAN_TYPE                   = 3;
  const unsigned short      NODE_SET_TYPE                  = 4;
  const unsigned short      SINGLE_NODE_TYPE               = 5;

These are not available through the XPathEvaluator interface, and therefore
can not be used prior to evaluation, unless using a two stepp process via
the createResult method. The constants are used in the fourth parameter of
the evaluate method:

    XPathResult        evaluate(in DOMString expression,
                              in Node contextNode,
                              in XPathNSResolver resolver,
                              in unsigned short type,
                              in XPathResult result)

I am aware that there is a desire to minimize the number of fields grafted
to the Document interface, but a simple evaluationTypes attribute that
contained these constants would be very useful. For example:

    var barStr = document.evaluate("foo/@bar", document, null,
document.evaluationTypes.STRING_TYPE, null).stringValue;


Dominic.

Received on Thursday, 31 October 2002 09:32:16 UTC