org.apache.poi.util
Class XmlSort
- java.lang.Object
-
- org.apache.poi.util.XmlSort
-
public final class XmlSort extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classXmlSort.QNameComparatorImplements ajava.util.Comparatorfor comparingQNamevalues.
-
Constructor Summary
Constructors Constructor and Description XmlSort()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static voidmain(java.lang.String[] args)Receives an XML element instance and sorts the children of this element in lexicographical (by default) order.static voidsort(org.apache.xmlbeans.XmlObject element, java.util.Comparator<org.apache.xmlbeans.XmlCursor> comp)Sorts the children ofelementaccording to the order indicated by the comparator.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Receives an XML element instance and sorts the children of this element in lexicographical (by default) order.- Parameters:
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 sorted
-
sort
public static void sort(org.apache.xmlbeans.XmlObject element, java.util.Comparator<org.apache.xmlbeans.XmlCursor> comp)Sorts the children ofelementaccording to the order indicated by the comparator.- Parameters:
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 theQNames of two elements. SeeXmlSort.QNameComparatorfor 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.- Throws:
java.lang.IllegalArgumentException- if the inputXmlObjectdoes not represent an element
-
-
DataMelt 3.0 © DataMelt by jWork.ORG