XMLSORT(1p)

πŸ“¦
version 1.01 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– 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 -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. 🌈

πŸ¦‹ 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 (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