//  -*- c++ -*-

#include <kdebug.h>
#include <dom/dom_element.h>
#include <dom/dom_string.h>

#include "context.h"
#include "value.h"
#include "expression.h"

namespace XPath {

Value ExpressionNode::evaluate( const Context &/*context*/ )
{
    return Value();
}

bool ExpressionNode::match( const Context &/*context*/, const DOM::Node &/*node*/ )
{
    return false;
}

ExpressionAbbr::ExpressionAbbr( AbbrType ab, const QString &tok )
    : ExpressionNode( NodeAbbreviated ), abbr(ab), arg(tok)
{
}

Value ExpressionAbbr::evaluate( const Context &context )
{
    kdDebug() << "ExpressionAbbr::evaluate: abbr=" << (int) abbr << endl;

    DOM::Node n = context.current();
    if ( n.nodeType() == DOM::Node::ELEMENT_NODE ) {
	DOM::Element el( n );
	kdDebug() << "context is " << el.tagName().string() << endl;
    }

    switch( abbr ) {
	case AbbrCurrent:
	    return String( n.nodeName().string() );
	    break;
        case AbbrParent:
	    return String( n.parentNode().nodeValue().string() );
	    break;
	case AbbrChildren:
	    break;
	case AbbrDescendents:
	    break;
	case AbbrAttribute:
	    break;
	default:
	    break;
    };

    return String( "ExpressionAbbr" );
}

bool ExpressionAbbr::match( const Context &/*context*/, const DOM::Node &/*node*/ )
{
    return false;
}

}; // namespace XPath

// Local Variables:
// c-basic-offset: 4
// End:
