Class XmlNormalizer


  • public final class XmlNormalizer
    extends Object
    Toy utility that can be used to "normalize" or modify an XML file.

    WARNING: This is not standard XML normalization, but it can be useful.
    This can:

    • Pretty print file (indentation string can be specified).
    • Sorting
      • Sort all attributes.
      • Move some attributes to first position.
      • Sort all elements.
    • Scrambling
      • Scramble values of all attributes.
      • Scramble values of some attributes.
      • Scramble content of all elements.
      • Scramble content of some elements.
    • Removal
      • Remove all empty attributes.
      • Remove all pure elements.
      • Remove all comments.
      • Remove all elements that have a given name (before any local renaming).
      • Remove all attributes that have a given name (before any local renaming).
    • Renaming
      • Rename attributes names.
      • Rename elements names.
    • Setting
      • Set attributes values (of existing attributes).
      • Set elements contents (of existing elements that have a text child or not children).
    WARNING: Renaming may interact with other actions. It may be safe to rename in a separate step.
    Author:
    Damien Carbonne