/*
 * dom3xpath.idl
 *
 * DOM Level 3 XPath definitions, rewritten in Web IDL.
 *
 * Original OMG IDL:
 *
 *   http://www.w3.org/TR/2004/NOTE-DOM-Level-3-XPath-20040226/xpath.idl
 */

module xpath {

  typedef dom::Node Node;
  typedef dom::DOMObject DOMObject;
  typedef dom::Element Element;
  typedef dom::Document Document;
  typedef dom::DOMException DOMException;

  exception XPathException {
    // XPathExceptionCode
    const unsigned short      INVALID_EXPRESSION_ERR         = 51;
    const unsigned short      TYPE_ERR                       = 52;

    unsigned short   code;
  };

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

  Document implements XPathEvaluator;

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

  [Callback]
  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      UNORDERED_NODE_ITERATOR_TYPE   = 4;
    const unsigned short      ORDERED_NODE_ITERATOR_TYPE     = 5;
    const unsigned short      UNORDERED_NODE_SNAPSHOT_TYPE   = 6;
    const unsigned short      ORDERED_NODE_SNAPSHOT_TYPE     = 7;
    const unsigned short      ANY_UNORDERED_NODE_TYPE        = 8;
    const unsigned short      FIRST_ORDERED_NODE_TYPE        = 9;

    readonly attribute unsigned short  resultType;
    readonly attribute double          numberValue getraises(XPathException);

    readonly attribute DOMString       stringValue getraises(XPathException);

    readonly attribute boolean         booleanValue getraises(XPathException);

    readonly attribute Node            singleNodeValue getraises(XPathException);

    readonly attribute boolean         invalidIteratorState;
    readonly attribute unsigned long   snapshotLength getraises(XPathException);

    Node               iterateNext()
                                        raises(XPathException, 
                                               DOMException);
    Node               snapshotItem(in unsigned long index)
                                        raises(XPathException);
  };

  interface XPathNamespace : Node {

    // XPathNodeType
    const unsigned short      XPATH_NAMESPACE_NODE           = 13;

    readonly attribute Element         ownerElement;
  };
};
