XMLSORT(1p)
π XMLSORT β¨
okay so bestie, welcome to xmlsort β it's the XMLSORT(1p) manual page, and it's literally here to sort the 'records' in your XML files. no cap. π
πΈ NAME πΈ
xmlsort β sorts 'records' in XML files π¦
β SYNOPSIS β
xmlsort -r=<recordname> [ <other options> ] [ <filename> ]
Options:
-r <name> name of the elements to be sorted
-k <keys> child nodes to be used as sort keys
-i ignore case when sorting
-s normalise whitespace when comparing sort keys
-t <dir> buffer records to named directory rather than in memory
-m <bytes> set memory chunk size for disk buffering
-h help - display the full documentation
Example:
xmlsort -r 'person' -k 'lastname;firstname' -i -s in.xml >out.xml
look at that little example at the bottom. she's serving. π
π DESCRIPTION π
So the way this works: this script takes an XML document β either on STDIN or from a named file β and writes a sorted version of the file out to STDOUT. π«Ά
You have to use the -r option to identify the 'records' in the document, aka the bits you actually want sorted. Elements before and after the records will be unaffected by the sort β they just sit there, unbothered, main character energy but not in the sorting scene. π
π OPTIONS π
Here's a brief summary of the command line options (and the XML::Filter::Sort options which they correspond to). For more details, go peek at XML::Filter::Sort. π
-r <recordname>(Record) β The name of the elements to be sorted. This can be a simple element name like'person', or a pathname like'employees/person'β and heads up, that pathname version means only person elements contained directly within an employees element. π§-k <keys>(Keys) β A semicolon separated list of elements (or attributes) within a record which should be used as sort keys. Each key can optionally be followed by'alpha'or'num'to indicate alphanumeric or numeric sorting, and'asc'or'desc'for ascending or descending order. eg:-k 'lastname;firstname;age,n,d'. π₯-i(IgnoreCase) β This option makes sort comparisons case insensitive. π-s(NormaliseKeySpace) β By default all whitespace in the sort key elements is considered significant. Specifying-swill cause leading and trailing whitespace to be stripped and internal whitespace runs to be collapsed to a single space. π§Ή-t <directory>(TempDir) β When sorting large documents, it may be prudent to use disk buffering rather than memory buffering. This option lets you specify where temporary files should be written. πΎ-m <bytes>(MaxMem) β If you use the-toption to enable disk buffering, records will be collected in memory in 'chunks' of up to about 10 megabytes before being sorted and spooled to temporary files. This option lets you specify a larger chunk size. A suffix ofKorMindicates kilobytes or megabytes respectively. π
π¦ SEE ALSO π¦
This script uses the following modules:
XML::SAX::ParserFactory
XML::Filter::Sort
XML::SAX::Writer
three little modules, carrying the whole operation on their backs. iconic. β¨
π AUTHOR π
Grant McLean <grantm@cpan.org> π
π COPYRIGHT π
Copyright (c) 2002 Grant McLean. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Reminder bestie: that's the whole page, no skipped bits, we kept every option and every word that mattered. π
and that's a wrap π β this was perl v5.26.1, dated 2018-03-30, and it's the XMLSORT(1p) page, mwah π slay, go sort something, periodt. π
π¦ where this page comes from
- debian bookworm: libxml-filter-sort-perl 1.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libxml-filter-sort-perl 1.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: libxml-filter-sort-perl 1.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libxml-filter-sort-perl 1.01-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms