Java Code Examples for org.jdom2.Element#sortChildren()

The following examples show how to use org.jdom2.Element#sortChildren() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private void sort(Document document) {
    Comparator<Element> comparator = new DMNNodeComparator();

    // Sort definitions
    Element rootElement = document.getRootElement();
    if (rootElement != null) {
        rootElement.sortChildren(comparator);

        // Sort decision
        Element decision = rootElement.getChild("decision", Namespace.getNamespace("dmn", DMN_11.getNamespace()));
        if (decision != null) {
            decision.sortChildren(comparator);
        }
    }
}
 
Example 2
private static void sortAttributes(Document userXML) {
    Element attributes = userXML.getRootElement().getChild("attributes");
    if (attributes == null) {
        return;
    }
    attributes.sortChildren(Comparator.comparing(o -> o.getAttributeValue("name")));
}
 
Example 3
@Override
public Element createXML() throws MCRException {
    final Element xml = super.createXML();

    contentList.stream().map(Content::clone).forEach(xml::addContent);

    xml.sortChildren(
        Comparator.comparingInt(MCRMetaEnrichedLinkID::getElementPosition)
            .thenComparing(contentList::indexOf));

    return xml;
}
 
Example 4
public static void sort(Element mods) {
    mods.sortChildren(MCRMODSSorter::compare);
}