public Object exec(List arguments) {
Set names = new HashSet(arguments);
List list = new LinkedList(nodes);
Iterator it = list.iterator();
while (it.hasNext()) {
Object node = it.next();
String name = null;
if (node instanceof Element)
name = ((Element)node).getName();
else if (node instanceof Attribute)
name = ((Attribute)node).getName();
else if (node instanceof ProcessingInstruction)
name = ((ProcessingInstruction)node).getTarget();
else if (node instanceof EntityRef)
name = ((EntityRef)node).getName();
else if (node instanceof DocType)
name = ((DocType)node).getPublicID();
if (name == null || !names.contains(name))
it.remove();
}
return createNodeListModel(list, namespaces);
}
|