/*
 * Copyright (c) 2001 World Wide Web Consortium,
 * (Massachusetts Institute of Technology, Institut National de
 * Recherche en Informatique et en Automatique, Keio University). All
 * Rights Reserved. This program is distributed under the W3C's Software
 * Intellectual Property License. This program is distributed in the
 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE.
 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
 */

// File: http://www.w3.org/TR/2001/WD-DOM-Level-3-XPath-20011031/xpath.idl

#ifndef _XPATH_IDL_
#define _XPATH_IDL_

#include "dom.idl"

#pragma prefix "dom.w3c.org"
module xpath
{

  typedef dom::DOMString DOMString;
  typedef dom::Node Node;
  typedef dom::Element Element;

  interface XPathNSResolver;
  interface XPathResult;
  interface XPathExpression;
  interface XPathSetIterator;
  interface XPathSetSnapshot;

  exception XPathException {
    unsigned short   code;
  };
  // XPathExceptionCode
  const unsigned short      INVALID_EXPRESSION_ERR         = 1;
  const unsigned short      TYPE_ERR                       = 2;


  interface XPathEvaluator {
    XPathExpression    createExpression(in DOMString expression, 
                                        in XPathNSResolver resolver)
                                        raises(XPathException, 
                                               dom::DOMException);
    XPathResult        createResult();
    XPathNSResolver    createNSResolver(in Node nodeResolver);
    XPathResult        evaluate(in DOMString expression, 
                                in Node contextNode, 
                                in XPathNSResolver resolver, 
                                in unsigned short type, 
                                in XPathResult result)
                                        raises(XPathException, 
                                               dom::DOMException);
  };

  interface XPathExpression {
    XPathResult        evaluate(in Node contextNode, 
                                in unsigned short type, 
                                in XPathResult result)
                                        raises(XPathException, 
                                               dom::DOMException);
  };

  interface XPathNSResolver {
    DOMString          lookupNamespaceURI(in DOMString prefix);
  };

  interface XPathResult {

    // XPathResultType
    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;

    readonly attribute unsigned short  resultType;
    readonly attribute double          numberValue;
                                        // raises(XPathException) on retrieval

    readonly attribute DOMString       stringValue;
                                        // raises(XPathException) on retrieval

    readonly attribute boolean         booleanValue;
                                        // raises(XPathException) on retrieval

    readonly attribute Node            singleNodeValue;
                                        // raises(XPathException) on retrieval

    XPathSetIterator   getSetIterator(in boolean ordered)
                                        raises(XPathException, 
                                               dom::DOMException);
    XPathSetSnapshot   getSetSnapshot(in boolean ordered)
                                        raises(XPathException, 
                                               dom::DOMException);
  };

  interface XPathSetIterator {
    Node               nextNode()
                                        raises(dom::DOMException);
  };

  interface XPathSetSnapshot {
    Node               item(in unsigned long index);
    readonly attribute unsigned long   length;
  };

  interface XPathNamespace : Node {

    // XPathNodeType
    const unsigned short      XPATH_NAMESPACE_NODE           = 13;

    readonly attribute Element         ownerElement;
  };
};

#endif // _XPATH_IDL_

