Start
   Blogaria
   Bored
   bsgen
   c-conf
   Cookies
   cycliclog
   Dialwhatever
   dnspb
   fch
   fe
   fswatch
   HammerServer
   His
   jpeginfo
   kalk
   Lectures
   Microproxy
   msc
   Nasapics
   Off The Grid
   PGPkey
   Posters
   SafeEdit
   Simple listserv
   syscheck
   tcp-fwd
   Wallpapers
   xml tools
Karel as an adult



XML Tools

The package "xml tools" is a simple (Perl) wrapper around some XML-inspecting tools that I often use, and which I find quite handy.

How to get it

How to invoke it

The general invocation is xml ACTION ARGS, where the action defines what happens. To see usage information, just run xml and it'll show what's possible. The below sections show in general what xml can do. Refer to the usage information to see full lists of options (flags) - i.e., start xml without parameters.

xml prettyprint FILE

Prettyprints the named file, output appears on stdout. Use file name - to read input from stdin. The optional flag -o overwrites the file "in place".

Note that prettyprinting can modify the literal contents (though not the semantics). Particularly, <root><trunk/></root> will get converted to

  <root>
    <trunk></trunk>
  </root> 

xml xpath FILE

This is a simple inspection method. All non-empty leaves are shown in an xpath format. For example:
<root material="wood">
  <trunk>
    <branch>
      <leaf color="green">A bug sits here.</leaf>
      <leaf>This leaf is not occupied.</leaf>
    </branch>
    <branch>
      <leaf color="brown">This leaf is about to fall off.</leaf>
    </branch>
  </trunk>
</root>
leads to the output:
/root/@material = wood
/root/trunk/branch/leaf/@color = green
/root/trunk/branch/leaf = A bug sits here.
/root/trunk/branch/leaf = This leaf is not occupied.
/root/trunk/branch/leaf/@color = brown
/root/trunk/branch/leaf = This leaf is about to fall off.

xml xsd FILE(s)

Shows the XSD (XML Schema Defintion) declarations of the given files.

xml xsdcheck FILE(s)

Per file, the XSD type is determined, and the file is checked against the proper XSD. XSD's are expected in /usr/local/lib/xml/xsd/.

If your XML file has an XSD that isn't present in /usr/local/lib/xml/xsd/, then either:

xml yaml FILE

This is another quick-inspector. The above shown XML appears as YAML:
---
material: wood
trunk:
  branch:
    - leaf:
        - color: green
          content: A bug sits here.
        - This leaf is not occupied.
    - leaf:
        color: brown
        content: This leaf is about to fall off.