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

The following examples show how to use org.jdom2.Element#sortChildren() . 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
Source File: AbstractRDFToDMNTransformerTest.java    From jdmn with Apache License 2.0 5 votes vote down vote up
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
Source File: MCRUserTransformer.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
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
Source File: MCRMetaEnrichedLinkID.java    From mycore with GNU General Public License v3.0 5 votes vote down vote up
@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
Source File: MCRMODSSorter.java    From mycore with GNU General Public License v3.0 4 votes vote down vote up
public static void sort(Element mods) {
    mods.sortChildren(MCRMODSSorter::compare);
}