Sie zeigen eine alte Version dieser Seite an. Zeigen Sie die aktuelle Version an.

Unterschiede anzeigen Seitenhistorie anzeigen

« Vorherige Version anzeigen Version 4 Aktuelle »


You may use the builtin xpath engine to evaluate your own xpath expressions any time in your code. The following examples shows how the xpath engine is used within an own action implementation.
This implementation will address all list items underneath which matches a certain pattern. The pattern is based on a field value from another type.

 

See class com.jaxfront.demo.api.XPathAction
public class XPathAction implements Action { 
public void perform(Type source) {
Type patternType = source.getChild("simpleGroup").getDirectChild("A");
String pattern = source.getChild("simpleGroup").getDirectChildValue("A");
String xpath = ".//A[.='" + pattern + "']"; 
ListType listType = (ListType)source.getDirectChild("list");
List found = TypePathExecuter.getInstance().processXPath(listType, xpath); 
AbstractView view = (AbstractView)TypeVisualizerFactory.getInstance().getVisualizer(patternType);
String message = "Found (" + found.size() + " items) for XPath ("+ xpath + "). Going to delete them...";
view.showHint(message, false, Color.RED, true); 
Iterator iterator = found.iterator();
while (iterator.hasNext()) {
listType.removeChild(((Type)iterator.next()).getParent());
}
}
} 
  • Keine Stichwörter