XMLSORT(1)

πŸ“¦ version 1.01, in nixos 26.05, nixpkgs unstable

πŸ’– NAME πŸ’–

okay so this is the XMLSORT(1) manual page, bestie β€” from User Contributed Perl Documentation β€” and it does exactly one iconic thing: sorts 'records' in XML files. no cap.

✨ 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

🌸 DESCRIPTION 🌸

So basically this script takes an XML document either on STDIN or from a named file, and writes a sorted version of the file to STDOUT. The -r option is the one you use to identify the 'records' in the document β€” like, the actual bits you want sorted. Elements before and after those records will be unaffected by the sort. periodt. πŸ’…

πŸŽ€ OPTIONS πŸŽ€

Here's the brief lil summary of the command line options (and the XML::Filter::Sort options they correspond to). For more details, see 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' (which means only person elements contained directly within an employees element).
  • -k <keys> (Keys) β€” semicolon separated list of elements (or attributes) within a record that 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 (e.g. -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 -s will 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 -t option 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 of K or M indicates kilobytes or megabytes respectively.
  • -h β€” help; displays the full documentation.

πŸ¦‹ SEE ALSO πŸ¦‹

This script uses the following modules:

  XML::SAX::ParserFactory
  XML::Filter::Sort
  XML::SAX::Writer

πŸ‘‘ AUTHOR πŸ‘‘

Grant McLean <grantm@cpan.org>

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.


okay bestie, that's the whole manual β€” source/version is perl v5.42.3, dated 2005-04-20. slay and goodbye πŸ’…βœ¨

πŸ“¦ where this page comes from