log 0, 'remove title from dedication'
xml.css('dedication title')[0].content = ""
+log 0, 'move legal notice to bookinfo'
+xml.css('book bookinfo')[0].first_element_child.before('<legalnotice>')
+ln = xml.css('book bookinfo legalnotice')[0]
+xml.css('para').each do |para|
+ if para.content =~ /This book is published under a/
+ log 0, 'found legal'
+ para.parent = ln
+ break
+ end
+end
+
log 0, 'Writing processed file'
# Unable to figure out API way to replace DOCTYPE
data = xml.to_xml().gsub!(/DOCTYPE article/, 'DOCTYPE book')