27 #include "xml/dom_docimpl.h"
28 #include "xml/dom_nodeimpl.h"
31 using namespace khtml;
32 using namespace khtml::XPath;
36 m_predicates( predicates )
43 qDeleteAll( m_predicates );
50 foreach(
Predicate *predicate, m_predicates ) {
51 s += predicate->
dump();
57 Value Filter::doEvaluate()
const
61 if ( !m_predicates.empty() ) {
62 kDebug(6011) <<
"Ignoring predicates for filter since expression does not evaluate to a nodeset!";
70 inNodes->normalizeUpto(StaticNodeListImpl::DocumentOrder);
72 foreach(
Predicate *predicate, m_predicates ) {
73 outNodes =
new StaticNodeListImpl();
76 for (
unsigned long n = 0; n < inNodes->length(); ++n ) {
77 NodeImpl *node = inNodes->item(n);
82 outNodes->append( node );
87 outNodes->setKnownNormalization(StaticNodeListImpl::DocumentOrder);
90 kDebug(6011) <<
"Predicate within filter trims to:" << outNodes->length();
94 return Value( outNodes );
104 qDeleteAll( m_steps );
109 foreach(
Step *step, m_steps ) {
114 Value LocationPath::doEvaluate()
const
118 kDebug(6011) <<
"Evaluating absolute path expression, steps:" << m_steps.count();
120 kDebug(6011) <<
"Evaluating relative path expression, steps:" << m_steps.count();
132 if ( context->nodeType() != Node::DOCUMENT_NODE ) {
133 context = context->ownerDocument();
137 inDomNodes->append( context );
139 if ( m_steps.isEmpty() )
140 return Value( inDomNodes );
143 foreach(
Step *step, m_steps ) {
145 kDebug(6011) <<
"-------------------------------------";
146 kDebug(6011) <<
"Step " << s <<
"insize " << inDomNodes->length();
149 outDomNodes =
new StaticNodeListImpl;
150 for (
unsigned long i = 0; i < inDomNodes->length(); ++i ) {
152 for (
unsigned long j = 0; j < matches->length(); ++j )
153 outDomNodes->append( matches->item( j ) );
155 inDomNodes = outDomNodes;
161 kDebug(6011) <<
"-------------------------------------";
162 kDebug(6011) <<
"output:" <<outDomNodes->length();
163 kDebug(6011) <<
"=====================================";
166 return Value( outDomNodes );
171 QString s =
"<locationpath absolute=\"";
172 s += m_absolute ?
"true" :
"false";
174 foreach(
Step *step, m_steps ) {
177 s +=
"</locationpath>";
182 : m_filter( filter ),
195 if ( !m_filter && !m_path ) {
201 s += m_filter->
dump();
211 Value Path::doEvaluate()
const
221 for (
unsigned long i = 0; i < in->length(); ++i) {
225 for (
unsigned long j = 0; j < singleSet->length(); ++ j)
226 out->append(singleSet->item(j));
virtual QString dump() const
SharedPtr< DOM::StaticNodeListImpl > DomNodeList
static QDebug kDebug(bool cond, int area=KDE_DEFAULT_DEBUG_AREA)
virtual QString dump() const =0
virtual QString dump() const
virtual QString dump() const
static EvaluationContext & evaluationContext()
DomNodeList evaluate(DOM::NodeImpl *context) const
static void reportInvalidExpressionErr()
Path(Filter *filter, LocationPath *path)
virtual Value evaluate() const
DomNodeList & toNodeset()