KVH-format
You are on the official home page for Key-Value-Hierarchy
(KVH) format project.
Here you will find the format description, parser examples and, may be
in future,
examples of real word applications using this format.
Last updated: 17 March 2004.
Introduction
This project was started as a light weight alternative to a well known
and well spread eXtensible Mark-up Language (XML). XML is very flexible
and universal but sometimes, it is just too heavy to be incorporated in
a light weight project. KVH format is designed for inter application
exchanges. Applications are supposed to be written in various languages
and running on various platforms.
KVH in a nutshell
This format uses three and only
three reserved characters : '\t' (tabulation), '\n' (new line) and '\\'
(backslash).
- '\t' is used to separate key from value and to indent different
levels of hierarchy;
- '\n' is used to separate rows. A row contains a key-value pair.
- '\\' is used to escape these three characters if they are part of
a key or value.
Using KVH, you can elaborate a hierarchy of named parameters suitable
for
your application and easily write a parser for information exchanges.
For more detailed description of KVH format click here.
KVH advantages
- The main advantage is an extreme light weight of kvh parsers
combined with very flexible data structures.
- Using of UTF-8 encoded text is straight forward.
- Platform and programing language independent.
- Tolerant for application evolution. If your evolving application
needs at some point additional keys, your old versions are still able
to read and parse knew files. Your application just need to be written
in such a way that it ignores (or just warns on) unknown keys. Do you
remember what a mess it was when people start to use attached files in
emails and some clients were not yet aware of this feature ? Such
situation might be avoided, if an appropriate format were used for
client-server exchanges.
- Mixing of binary and text data is allowed with a very small
overhead for encoding of binary data. You have just to escape two
reserved characters ('\n' and '\\') if they occur in your binary data
in 'value' field. Be aware that, even allowed, using of raw binary data
may render your kvh files platform dependent and may trouble debugging
of your data in classical text editors.
KVH limitations
- You have to elaborate your own hierarchy of meaningful keys (keys
are variable or field names) which will be restricted to a given
application or, at the best, to a given activity domain. This is
applicable to XML too.
- Unlike in XML, there is no consistency check. If, by mistake, you
use a non appropriate key or a good key but in wrong place, there is
nothing if format that prevents you from doing this. In XML you have
dtd that may play a role of watchdog. So, it's your application that
has to take an appropriate care of such situation.
Examples
- running examples : output
of php parser, Tree
viewer
(needs a Java enabled navigator and javascript activated).
- kvh files : hello.kvh (traditional
"hello world" example), hello_salut.kvh
("hello world" translated in french), specials.kvh
(some special cases which can occur in kvh file.);
- sources of toy parsers : in php, in C, in Java (applet) ;
Feedback
You may send your constructive critics and suggestions to the author
Serguei Sokol (ssokol-AT-chez.com) till the end of 2004.
Copyright 2004, Serguei Sokol (ssokol-AT-chez.com).
You may copy and distribute this document under GNU Free Documentation
License.