Versionen im Vergleich

Schlüssel

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


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. Image Removed

 

Hinweis
See class com.jaxfront.demo.api.XPathAction
Codeblock
themeEclipse
languagejava
linenumberstrue
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());

...


}

...


}

...


}