List of usage examples for org.dom4j DocumentHelper sort
public static void sort(List<Node> list, String xpathExpression)
sort
sorts the given List of Nodes using an XPath expression as a java.util.Comparator .
From source file:com.liferay.portal.xml.SAXReaderImpl.java
License:Open Source License
public void sort(List<Node> nodes, String xPathExpression) { DocumentHelper.sort(toOldNodes(nodes), xPathExpression); }
From source file:de.innovationgate.utils.WGUtils.java
License:Apache License
/** * Sorts the child elements of an element based on their indiviual XPath * result. This utility method should be used instead of direct sorting of * the elements()-list of a parent element, since this will fail with * exception on most occasions./*from w ww.j a v a2 s . c o m*/ * * @param parent * The parent element * @param xpath * The xpath that is evaluated on each child element */ @SuppressWarnings({ "unchecked", "rawtypes" }) public static void sortChildElements(Element parent, String xpath) { // Create a copy of the elements list and sort it List list = new ArrayList(parent.elements()); DocumentHelper.sort(list, xpath); // Iterate over sorted list. Remove and add all in order Iterator it = list.iterator(); while (it.hasNext()) { Element element = (Element) it.next(); parent.remove(element); parent.add(element); } }
From source file:de.innovationgate.wga.common.WGAXML.java
License:Apache License
/** * get all defined domainElements in wga.xml * @param wgaXMLElement - an element of wga.xml * @return domain elements sorted by name *///w ww .java 2 s. c o m public static List getDomainElements(Element wgaXMLElement) { List domains = wgaXMLElement.selectNodes("/wga/domains/domain"); DocumentHelper.sort(domains, "@name"); return domains; }