#!/usr/bin/python
# -*- coding: utf-8 -*-

import bsddb.db
import dbxml

books = {
    'short' : '<short />',
    'oui oui' : '<book><title>Oui oui à la plage</title></book>',
    'la démocratie' : '<book><title>Science politique - 1. La démocratie</title><author>Philippe Braud</author><chapter><title>La question des origines</title></chapter><chapter><title>La democratie comme reference mobilisatrice</title></chapter></book>',
    'article' : '''<?xml version="1.0"?>
<article xmlns="http://www.entrouvert.org/namespaces/expression/0.0">
  <title>This is the article title</title>
  <body>This is the article body.&#13;
Just for testing.</body>
</article>''',
    'article2' : '''<?xml version="1.0"?>
<article xmlns="http://www.entrouvert.org/namespaces/expression/0.0">
  <title>Another article</title>
  <body>Bla bla bla.</body>
</article>''',
}

container = dbxml.XmlContainer(None, "test.dbxml")
container.open(None, dbxml.DB_CREATE)

for name in books.keys():
    document = dbxml.XmlDocument()
    document.setName(name)
    document.setContent(books[name])
    container.putDocument(None, document)

container.close()
