I plan to look at moving my snipsnap bliki to wordpress, i.e, here. This snip was originally placed on that site. I have transferred it for one reason because it contains xml tags which xslt has problems dealing with. This article consists of my notes made while designing a transfer mechanism.

This page is currently structured as follows, there’s a section called Previous Projects which documents Ryan Barret’s code that moved from snipsnap to pybloxom vi subversion, there’s a section on the wrx schema, and some notes on how I might just run a script against the file system.

In June 2013, I cleaned up a dump file which I used to restore the bliki and bring it back online. I hope I have removed all snips that contain the string <![CDATA[…..]]>, which would be those in which I inserted Disqus comments and this snip, which recorded my notes on WRX. This may make the xslt solution more feasible. I need to buy a book.

Previous Projects

Ryan Barret at http://snarfed.org has already done this, so I hope his resources are helpful. He used xsltproc, and wordpress uses xml as its import/export medium. I wrote to Ryan, who pointed me at the following

by him, and also

This last article describes how to change Snipsnap to create an RSS file of more than 10 articles. I have been looking at how to use the {weblog} macro to extend the RSS file, it seems that this will have no effect on the RSS , if I could get it to work, then the blog page would be bigger but the RSS would not. The author of snipsnap to wordpress used RSS as his base source. This has some advantages over using the dump, which is what I was planning to use.

Inspired by Ryan my first plan was to learn xslt and write an xslt script that would convert the dump from snipsnap dump xml format to WRX, but having seen how simple a wordpress RSS file is, it might be simpler to write a script in bash or python.


and an article at stackoverflow, which includes a book list


The namespace files for WRX can be discovered by undertaking an EXPORT. The format and rules are best explained at WRX explained at the Developer’s Tidbit. The namespaces used are,

<rss version="2.0"
xmlns\:wp="http://wordpress.org/export/1.1/" >

The WRX content looks like this.

  <wp:cat_name><![CDATA[About Me]]></wp:cat_name>

  <title>Sample Page</title>
  <pubDate>Thu, 02 Jun 2011 23:01:28 +0000</pubDate>
  <guid isPermaLink="false">http://wpress.davelevy.info/?page_id=2</guid>
  <content:encoded><![CDATA[This is an example page....]]></content:encoded>
  <wp:post_date>2011-06-03 01:01:28</wp:post_date>
  <wp:post_date_gmt>2011-06-02 23:01:28</wp:post_date_gmt>

I wonder how to assign labels/categories to items.

The input is more complex, it might be best to use Ryan’s script since it is so complex. We have the following cases, I think,

  • a simple snip, with no comments, attachments and no category set, versions = 1versions > 1
  • comments > 0
  • attatchments > 1
  • type = blog, which may have to be taken from the name attribute, and the transformation needs to deal with the name
  • type = category

I have a seperate wiki page that deals with the contents of the <content:encoded> element, called Converting a Snip.

Scripting by Hand

This is probably only poissible because I used the file system as my persistence provider. The top level directory consists of snips, which are directories, property files and content files, which in the case of the top level directory for user ‘Dave’ consist of two image files. The snip text content is help in content.txt. The other attributes are held in a file called metadata.properties.

I need to write a recursive walk, since snips can contain snips. A directory contains, property files, content files and directories which represent comments, versions and sub-snips. The snip taxonomy is best discovered using using the find UNIX utility. I need to flatten it out anyway, since wordpress does not support that hierarchy, although wxr does have a parent field.

I have some python code that looks to extract the necessary meta data.

The time facts are held in milli-seconds since epoch so the following python code converts it into human readable form and places it in dictionary D.

import time
myformat = '%a, %d %b %Y %H:%M:%S +0000'
D = {}
msecsinepoch = myfuntion() 
pubdate = time.strftime(myformat, time.gmtime(msecsinepoch/1000))
D['publicationdate'] = pubdate

gmtime requires seconds as an argument, hence msecsinepoch/1000. The other wxr elements need another format statement. myfunction returns the snipsnap held value of time in milliseconds. It’s an integer. In the code example above, the dictionary assignment statement hard codes the dictionary key as a string ‘publicationdate’.

I also have three snips which contain the ‘.’ character.

5 Replies

  1. I have tried to strip out the snips containing WRX from the dumpfile, using visual inspection and ‘sed’, but this is proving difficult.

    I have tried to exclude the snips containing xml from the xml dump, but chrome renders the xml into html and makes it unusable 🙁

    I have tried to use sed to make the XML unrecognisable to the xslt script, but this doesn’t yet work. I may need to change out the “<" character. However, my bliki uses the file system as its persistence technology. I am considering removing the offending snips from the data store using 'rm', but on investigation, it might be much easier to write a shell script in bash, or python. 😈

  2. I eventually tranferred them by hand. WordPress’s drag and drop is pretty cool and a lot of the blog articles didn’t warrant being copied since they were pointers to the wiki to cover up the poor RSS fetures of snipsnap.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.