W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2002

XPath Evaluation Types Are Not Easily Available Prior To Evaluation

From: Dominic Chambers <dominic.chambers@bigfoot.com>
Date: Thu, 31 Oct 2002 01:26:41 -0500 (EST)
Message-ID: <007501c280a6$38031dd0$0100a8c0@hp>
To: <www-dom@w3.org>




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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:56 GMT