\\
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.
\\
Wiki-Markup
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! _
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());
\}
\}
\}
\\
\\
}
}
}