xml-canonic
Canonicalize XML documents
TLDR
Make an XML document canonical, preserving comments
Make an XML document canonical, removing comments
Make XML exclusively canonical, using an XPATH from a file, preserving comments
Display help
SYNOPSIS
xml-canonic [OPTIONS] [FILE...]
PARAMETERS
-w, --with-comments
Includes comments in the canonical form. By default, comments are stripped according to C14N 1.0.
-s, --strip-comments
Explicitly strips comments from the output. This is the default behavior for standard C14N 1.0.
-e, --exclusive
Applies Exclusive XML Canonicalization (Exc-C14N). This variant minimizes the namespace declarations by only including those that are strictly necessary for the current element and its ancestors.
-p, --prefix-list LIST
Used only with --exclusive. Specifies a space-separated LIST of namespace prefixes to omit from the canonical form, even if they would otherwise be included by Exc-C14N rules.
-h, --help
Displays a help message and exits.
-v, --version
Displays version information and exits.
DESCRIPTION
xml-canonic is a command-line utility designed to perform XML Canonicalization on XML documents.
It reads XML from specified files or standard input, then writes the canonicalized output to standard output.
The primary purpose of XML canonicalization (C14N) is to bring an XML document into a standard, deterministic physical representation.
This ensures that two XML documents that are logically equivalent (e.g., differing only in whitespace, attribute order, or namespace declarations) will produce the exact same byte-for-byte output after canonicalization.
This property is crucial for applications such as XML Digital Signatures, where even minor, semantically insignificant changes would invalidate a signature.
It supports the standard XML Canonicalization Version 1.0 (C14N) and Exclusive XML Canonicalization (Exc-C14N).
CAVEATS
xml-canonic primarily implements XML Canonicalization Version 1.0 and Exclusive XML Canonicalization.
It does not support newer canonicalization algorithms like C14N 1.1.
It expects well-formed XML input and may behave unexpectedly or fail on malformed documents.
Complex DTD processing or external entity resolution might not be fully handled as per advanced XML parsers.
HISTORY
xml-canonic is part of the xml-core package, which provides essential command-line utilities for XML processing on Linux systems, particularly Debian-based distributions.
Its development is closely tied to the evolution and widespread adoption of XML Canonicalization specifications, crucial for security-related XML standards like XML Digital Signatures and XML Encryption.
While its core functionality remains stable, the underlying libraries and package maintenance ensure its compatibility with modern XML standards and system environments.
SEE ALSO
xmllint(1), xmlstarlet(1), xsltproc(1)