Public | Automated Build

Last pushed: a year ago
Short Description
Copies the official Dutch legislation repository (BWB) to a CouchDB database
Full Description

⚠ This repository is no longer mantained

Dutch government has changed (and greatly improved) its open data service which now completely overshadows this project. This repository now only serves as an artifact of history.

BWB Mirror

This project contains some scripts to clone Dutch laws from the official government CRM to a CouchDB database. The
resulting database is faster, easier to use and keeps track of laws through time. We also generate a table of contents.


While the Dutch government publishes Dutch laws through their own BWB service, some problems exist with it:

  • The service is very slow
  • Only one version of a law (the current) is available; there are no historical consolidations available
  • Bulk requests are awkward (we can only download a
    metadata dump for all laws as a zip file)

While the MetaLex Document Server solves the first two of these problems, and arguably the
third, it also introduces problems, like it performs destructive XML transforations and throws away the source material.
Also, the MDS has not been updated since April 2014.

Updater usage


Install Docker.

# Run from Docker registry
docker run \
       -ti \


Install Ruby 2.1.6

Set environment variables:

COUCH_URL_WETTEN URL to a CouchDB database
COUCH_USER_WETTEN username for CouchDB database
COUCH_PASSWORD_WETTEN password for CouchDB database

Run script:

gem install bundler
bundle install
ruby update_couch_db

Database usage

The reference database is hosted at Read access is public.

Following the standard CouchDB Document API, one may access any
document through the _all_docs view with some query parameters set, .e.g,:"BWBR0002178"&endkey="BWBR0002179"

This will show full documents, but we may be interested in just the metadata. I have defined some additional views:

View name Description Example
all_from_metalex Like all, but shows only index files that have been converted from MetaLex
all_non_metalex Like all, but shows only index files that have not been converted from MetaLex
countKinds Summary showing the number of documents pertaining to a certain kind (e.g.: law, circulaire, etc.)

Some technical notes

Documents are stored as CouchDB JSON-files with metadata fields that are not exactly the same as the XML elements.
Compare XmlConstants.rb with JsonConstants.rb. An attachment called data.xml contains the document content,
unsurprisingly in XML format. Document IDs are of the form {BWBID}:{EXPRESSION DATE}, where the expression date is
specified by the field datumLaatsteWijzing (date last modified).

Note that a field called "xml" has been added to the documents, which should always be null. This is a remnant of
early iterations of the database in which document content was inlined along with the metadata. The reasoning was
that bulk requests are easier this way. However, metadata does not get compressed, as attachments do. Also inlining XML
made it harder to query documents just for their metadata, needing secondary queries.

Docker Pull Command
Source Repository