Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.
Kommentar: Migrated to Confluence 4.0


Wiki-Markup\\ 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. \\ !worddav2f51b87e377051db4caf28225cc7f883.png|height=32,width=29! _
Image Added com.jaxfront.demo.api.XPathAction_
public class XPathAction implements Action \{ \\ public void {
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 listType = (ListType)source.getDirectChild("list");
List found = *TypePathExecuter.getInstance().processXPath{*}(listType, xpath); \\ AbstractView view =
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 =
Iterator iterator = found.iterator();
while (iterator.hasNext()) \{ {
listType.removeChild(((Type)iterator.next()).getParent()); \} \} \} \\ \\
}
}
}