John A. Kunze


anvl - command to convert and manipulate ANVL records


anvl [--format format] [other_options] [file ...]


The anvl utility converts ANVL records to a variety of formats, including XML, Turtle, JSON, ANVL (long form), and Plain. An ANVL (A Name Value Language) record is a text-based sequence of elements ending in a blank line, where each element consists of a label, colon, and value and long values may be continued on subsequent indented lines.

This utility reads one or more file arguments (or the standard input if none) and writes on the standard output. The current version assumes input to be a stream of ANVL records. More information is given in the OPTIONS section.


The special label "erc" in front of a short form ERC (Electronic Resource Citation) record is recognized and the record is converted to long form before other processing is done.

   $ echo 'erc: a | b | c | d' | anvl --format json
       "erc": "",
       "who": "a",
       "what": "b",
       "when": "c",
       "where": "d"

Comments may be passed through to any output format; pseudo-comments are produced if the target format doesn't natively support comments.

   $ echo '# A way to kernel knowledge.
   > erc: Kunze, John A. | A Metadata Kernel for Electronic Permanence
   >      | 20011106 |
   > ' > myfile
   $ anvl --comments -m turtle myfile
   @prefix erc: <> .
   # A way to kernel knowledge.

       erc:erc """""" ;
       erc:who """Kunze, John A.""" ;
       erc:what """A Metadata Kernel for Electronic Permanence""" ;
       erc:when """20011106""" ;
       erc:where """""" .

The default conversion target is to the ANVL format, which does little except to expand short form ERCs and regularize some of the whitespace.

   $ anvl myfile
   who: Kunze, John A.
   what: A Metadata Kernel for Electronic Permanence
   when: 20011106

The verbose option can cause extra information to be output.

   $ echo 'a: b
   > #note to self
   > c: d' | anvl --verbose --comments -m xml
     <rec>   <!-- from record 1, line 1 -->
       <!-- #note to self -->

That XML conversion output can be converted back to the ANVL record,

   a: b
   c: d

with this style sheet

   <xsl:template match="/">
   <xsl:for-each select="recs/rec">
   <xsl:for-each select="*">
   <xsl:value-of select="local-name(.)"/>: <xsl:value-of select="."/>



Preserve comments during --format conversion, with pseudo-comments produced depending on the target format.

--find regexp

Only output records that match the regular expression, regexp. (The match is done before any expansion of short form ERCs.)

-m format[:order], --format format[:order]

Convert to the given format, currently one of "ANVL" (default), "XML", "Turtle", "JSON", "CSV", "PSV" (Pipe Separated Value), or "Plain". When converting comments to the JSON or Plain formats, pseudo-comments are output. Some options (below) apply only to specific target formats.

Optionally, format may be followed by a colon and order, which is a list of '|'-separated element names specifying particular set and ordering in which to output record elements. For example, "CSV:name|phone|email" specifies the "CSV" format with records consisting of exactly name, phone, and email. Currently, only the first instance of a named element in a record is output, and a missing element is output as if it had an empty value.


Convert element values that end with one or more commas (used in ANVL to designate sort-friendly values that may contain inversion points) to natural word order. The more terminal commas, the more inversion points tried. For example, the values

     Smith, Pat,
     McCartney, Paul, Sir,,
     Hu Jintao,

convert to the following natural word orderings

     Pat Smith
     Sir Paul McCartney
     Hu Jintao
-h, --help

Print extended help documentation.


Print known conversion formats.


Print full documentation.

--predns namespace

For Turtle conversion, use the given namespace for assertion Predicates, by default, "".

--show regexp

Show only those elements matching the regular expression, regexp. Matching, which can include labels and values, is done against a string (re-)constructing the element as a "label: value".

--subjelpat pattern

For Turtle conversion, use the given pattern as a regular expression to match the first instance of an ANVL element name in each input record, the corresponding value of which will become the Subject of Turtle assertions about the containing record. By default, the first element matching "^identifier$" or "^subject$" is used, unless the record appears to be an ERC (Electronic Resource Citation), in which case the first element matching "^where$" is used. Failing all else, the first non-empty element will be used.

-v, --verbose

Show more information, such as record numbers in output comments.


Print the current version number and exit.


A Name Value Language (ANVL)

A Metadata Kernel for Electronic Permanence (pdf)


John Kunze jak at ucop dot edu


Copyright 2009-2011 UC Regents. Open source BSD license.