public final class XmlSort
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
XmlSort.QNameComparator
Implements a
java.util.Comparator for comparing QName values. |
Constructor and Description |
---|
XmlSort() |
Modifier and Type | Method and Description |
---|---|
static void |
main(java.lang.String[] args)
Receives an XML element instance and sorts the children of this
element in lexicographical (by default) order.
|
static void |
sort(org.apache.xmlbeans.XmlObject element,
java.util.Comparator<org.apache.xmlbeans.XmlCursor> comp)
Sorts the children of
element according to the order indicated by the
comparator. |
public static void main(java.lang.String[] args)
args
- An array in which the first item is a
path to the XML instance file and the second item (optional) is
an XPath inside the document identifying the element to be sortedpublic static void sort(org.apache.xmlbeans.XmlObject element, java.util.Comparator<org.apache.xmlbeans.XmlCursor> comp)
element
according to the order indicated by the
comparator.element
- the element whose content is to be sorted. Only element children are sorted,
attributes are not touched. When elements are reordered, all the text, comments and PIs
follow the element that they come immediately after.comp
- a comparator that is to be used when comparing the QName
s of two
elements. See XmlSort.QNameComparator
for a simple
implementation that compares two elements based on the value of their QName, but more
complicated implementations are possible, for instance, ones that compare two elements based
on the value of a specifc attribute etc.java.lang.IllegalArgumentException
- if the input XmlObject
does not represent
an elementCopyright 2016 The Apache Software Foundation or its licensors, as applicable.