Closed Bug 95059 Opened 25 years ago Closed 24 years ago

Fix *Expr.cpp

Categories

(Core :: XSLT, defect)

defect
Not set
normal

Tracking

()

VERIFIED FIXED

People

(Reporter: axel, Assigned: axel)

Details

I looked over *Expr.cpp and found a few bugs: FilterExpr::matches must evaluate with context node, not node. TextExpr needs CDATA RootExpr::matches is wrong for multiple nodes. ElementExpr and AttributeExpr should get NameTestExpr, there is something bad with wildcards in there. BooleanExpr.cpp could use some newlines in if () Each file should have a comment with the XPath expression it implements
What is the context node when calling ::matches? A pattern matches if the tested node is part of the resulting nodeset when the expression is evaluated in *some* context, not any specific context. The only filter-expressions that are valid patterns are "id('Literal')" and "key ('Literal', 'Literal')" and neither of them are context sensitive. (Well, they are sensitive as to what document the context node lives in, and they only return nodes within that document.) I could imagine that there are some bugs in the interaction between PathExpr and FilterExpr wrt matching, but I would think that there is a bug in PathExpr in that case (though I could be wrong of corse). IMHO the context argument should be removed from ::matches (and ::getDefaultPriority) and I'll do that as soon as bug 84677 is checked in to avoid too much merge hell. If I'm totally wrong, could you provide an example pattern of when we need the context argument. I don't really understand what you mean about multiple nodes in RootExpr::matches since matching is done on one node at a time. IMHO we shouldn't spend too much time on ElementExpr and AttributeExpr since we should merge them into a NameTest class (which dosn't inherit Expr at all) as soon as bug 76070 is fixed.
not sure what way to do the dependency on bug 92786
Depends on: 92786
::matches is always with a context node. It's different to xpath's definition of matches. And FilterExpr uses the node to be tested as context, not the context node. And RootExpr::matches is wrong for multiple documents. Sorry, didn't say that precisely enough. Dep is the other way around, IMHO. Axel
No longer depends on: 92786
Blocks: 92786
I still think we should scrap the |Node* context| argument. Currently all implementations of ::matches returns true if the "node" argument matches in *some* (valid if you will) context. IMHO it should be the job of ::matches to test agains every valid context if it needs to. So what could be correct is if you in FilterExpr::matches walk up from the tree from the "node" argument and evaluate until you find get a resulting nodeset which contains the tested node. Don't worry about if it's slow since no valid patterns should produce a FilterExpr ;) Why is RootExpr::matches wrong wrt multiple documents? IMHO "/" should match the root of any document.
I should add an "I think" between "FilterExpr" and ";)"
You proboboly wanna do the same with FunctionCall::matches too. I'm still not sure if it's the RightThing yet though...
Ok. I have digged a bit further. ::matches is only used for XSLT Patterns and whitespace stripping. so... FilterExpr::matches should throw an assertion. IMHO. FunctionCall::matchse should throw an assertion if it's not key() or id(). context can go. RootExpr doesn't matter, as PathExpr will always stay within the same doc. Still contras? Axel
/me shakes hands with Pike Agreed :)
context must die in getDefaultPriority, too. I wonder if we should remove the assertion from Expr::getDefaultPriority and use it for all objects that return 0.5 Axel
IMHO no, since that's a good catch of if we've forgotten to implement ::getDefaultPriority somewhere.
Suckage. I just witnessed that @ped:* doesn't match ped:test="foo". AttributeExpr should bail out early if namespaceID == kNameSpaceID_XMLNS.
How much of this was fixed by contexts landing?
all.
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
we didn't verify for a long time. I really checked, so VERIFIED.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.