stash
This commit is contained in:
parent
913cda0721
commit
20d8545e3d
|
@ -16,16 +16,10 @@ public class XPathRootRuleElement extends XPathElement {
|
|||
|
||||
@Override
|
||||
public Collection<? extends ParseTree> evaluate(final ParseTree t) {
|
||||
// /* means whatever the root is
|
||||
if ( isWildcard() ) {
|
||||
ParserRuleContext ctx = (ParserRuleContext)t.getPayload();
|
||||
if ( ctx.getRuleIndex() == ruleIndex ) {
|
||||
return new ArrayList<ParseTree>() {{add(t);}};
|
||||
}
|
||||
else { // /x means x must be root
|
||||
ParserRuleContext ctx = (ParserRuleContext)t.getPayload();
|
||||
if ( ctx.getRuleIndex() == ruleIndex ) {
|
||||
return new ArrayList<ParseTree>() {{add(t);}};
|
||||
}
|
||||
}
|
||||
return new ArrayList<ParseTree>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,18 +13,13 @@ public class XPathTokenElement extends XPathElement {
|
|||
|
||||
@Override
|
||||
public Collection<? extends ParseTree> evaluate(ParseTree t) {
|
||||
if ( isWildcard() ) {
|
||||
return t.getChildren();
|
||||
}
|
||||
else {
|
||||
// return all children of t that match nodeName
|
||||
List<ParseTree> nodes = new ArrayList<ParseTree>();
|
||||
for (ParseTree c : t.getChildren()) {
|
||||
if ( c.getText().equals(nodeName) ) {
|
||||
nodes.add(c);
|
||||
}
|
||||
// return all children of t that match nodeName
|
||||
List<ParseTree> nodes = new ArrayList<ParseTree>();
|
||||
for (ParseTree c : t.getChildren()) {
|
||||
if ( c.getText().equals(nodeName) ) {
|
||||
nodes.add(c);
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue