{"id":314,"date":"2006-11-21T23:18:15","date_gmt":"2006-11-22T04:18:15","guid":{"rendered":"https:\/\/www.goer.org\/wordpress\/how_to_convert_authorit_to_docbook"},"modified":"2006-11-21T23:18:15","modified_gmt":"2006-11-22T04:18:15","slug":"how_to_convert_authorit_to_docbook","status":"publish","type":"post","link":"https:\/\/www.goer.org\/Journal\/2006\/11\/how_to_convert_authorit_to_docbook.html","title":{"rendered":"How to Convert AuthorIT to DocBook"},"content":{"rendered":"<p>Because the public demanded it! This is really just an overview of the process, but it should give you a basic idea about what to watch out for.<\/p>\n<ol>\n<li>\n<p><strong>Convert your <a href=\"http:\/\/author-it.com\/\">AuthorIT<\/a> book to <a href=\"http:\/\/en.wikipedia.org\/wiki\/DITA\">DITA<\/a>.<\/strong><\/p>\n<p><acronym>DITA<\/acronym> (Darwin Information Typing Architecture) is one of AuthorIT&#8217;s built-in publishing formats. Publishing to DITA results in a folder containing your book&#8217;s image files, a collection of <code>*.dita<\/code> files, and a <code>toc.ditamap<\/code> file.<\/p>\n<p>Sadly, you must take this opportunity to wave your index markers a fond farewell. They are apparently too old and frail to survive this stage of the journey.<\/p>\n<\/li>\n<li>\n<p><strong>Download the <a href=\"http:\/\/dita-ot.sourceforge.net\/\">DITA Open Toolkit<\/a>.<\/strong><\/p>\n<p>The DITA Open Toolkit (DITA-OT) is a collection of <a href=\"http:\/\/ant.apache.org\/\">Apache Ant<\/a> scripts, <a href=\"http:\/\/www.w3.org\/Style\/XSL\/\">XSL<\/a> stylesheets, and other goodies that enable you to transform DITA into other formats, including <a href=\"http:\/\/docbook.org\/\">DocBook<\/a>. For those of you who don&#8217;t live in the Java world, Ant is basically <code>make<\/code> for Java. Newer versions of DITA-OT conveniently include a copy of Ant, so you don&#8217;t need to install it separately.<\/p>\n<p>To install DITA-OT, unzip the toolkit&#8217;s files into any directory and run the <code>startcmd.sh<\/code> script (or <code>startcmd.bat<\/code> script on Windows) to configure your <code>CLASSPATH<\/code> and other environment variables. If you forget to set your <code>CLASSPATH<\/code>, the toolkit will helpfully indicate this to you by bailing out mid-transformation and complaining that the Ant script is broken.<\/p>\n<p>Before you run any DocBook transformations, edit <code>xsl\/docbook\/topic2db.xsl<\/code> and comment out the template that contains &#8220;Related links&#8221;. The only thing this template does is riddle your DocBook with invalid <code>itemizedlist<\/code> elements. <\/p>\n<p>Do not waste time reading the toolkit&#8217;s documentation. The manual that ships with DITA-OT 1.3 actually applies to DITA-OT 1.2, so most of the examples are broken. As for grammar and clarity, let&#8217;s just say that the manual&#8217;s translation from the original <a href=\"http:\/\/en.wikipedia.org\/wiki\/Old_Frisian\">Old Frisian<\/a> leaves much to be desired.<\/p>\n<\/li>\n<li>\n<p><strong>Transform the DITA document into DocBook.<\/strong><\/p>\n<p>All the toolkit&#8217;s transformations involve running an Ant script:<\/p>\n<pre><code>ant <var>options<\/var> <var>targets<\/var><\/code><\/pre>\n<p>To transform DITA to Docbook, run:<\/p>\n<pre><code>ant -Dargs.input=<var>path<\/var>\/toc.ditamap dita2docbook<\/code><\/pre>\n<p>If the transform fails (and all your environment variables are set correctly), there might be errors lurking in your generated DITA source. This is AuthorIT&#8217;s way of telling you, &#8220;Don&#8217;t let the door hit you on the way out, jerk!&#8221;<\/p>\n<ul>\n<li>If DITA-OT complains about a missing topic reference, there&#8217;s a good chance <code>toc.ditamap<\/code> is referencing a topic that doesn&#8217;t exist. Go back to the original AuthorIT doc and try to identify the missing topic. If all else fails, delete the reference from <code>toc.ditamap<\/code> and move on. Your readers already knew about the safety hazards of handling lithium deuteride, anyway.<\/li>\n<li>If a topic contains a <code>xref<\/code> with a crazy relative path, this can really confuse DITA-OT. The good news is that the toolkit indicates the path that is causing the problem. The bad news is that AuthorIT dumps its DITA output in UTF-16, which is really annoying to <code>grep<\/code> through. <\/li>\n<li>If you had any &#8220;Note&#8221; paragraph styles in your AuthorIT doc, these might disappear. Even more strangely, &#8220;Warning&#8221; paragraphs do make it through.<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>Clean up the DocBook output with a script.<\/strong><\/p>\n<p>Congratulations, your document is now DocBook! Well, more accurately, it&#8217;s &#8220;DocBook&#8221;. Just be happy your tables made it through, sort of.<\/p>\n<p>Fortunately, you can fix many issues pretty easily by running the document through a cleanup script. This script is particularly important if you&#8217;re converting multiple documents. The canonical language for the script is XSLT, but if you&#8217;d rather <em>stick it to the W3C Man<\/em>, Python or Perl would work fine too. Here&#8217;s what you&#8217;ll want to fix:<\/p>\n<ul>\n<li>Remove all <code>id<\/code> attributes. These generated IDs are duplicated throughout the doc, and nothing points to them. Throw them away and start over.<\/li>\n<li>Remove all <code>remap<\/code> attributes. In theory, these attributes contain useful information about the original DITA element, which in turn could help you design your post-processing script to provide better-quality DocBook markup. In practice&#8230; eh, not so much.<\/li>\n<li>Remove all <code>sectioninfo<\/code> elements. They&#8217;re often invalid, and always contain nothing useful.<\/li>\n<li>Remove empty <code>type<\/code> attributes. Not sure how those got there.<\/li>\n<li>Remove empty <code>para<\/code> elements.<\/li>\n<li>Change <code>sidebar<\/code> elements to <code>section<\/code> elements. Like the empty <code>type<\/code> attributes, these are another mystery guest.<\/li>\n<li>Join <code>programlisting<\/code> elements. If you had any multi-line code samples, you might find that in the transformed DocBook, each line appears in its own <code>programlisting<\/code>. Join adjacent <code>programlisting<\/code> elements into a single <code>programlisting<\/code> (or <code>screen<\/code>, if appropriate).<\/li>\n<li>(Optional) Change the <code>article<\/code> to a <code>book<\/code>, if appropriate. Add <code>chapter<\/code> elements as necessary.<\/li>\n<li>(Optional) Try to improve the quality of the markup by changing <code>emphasis role=\"bold\"<\/code> and <code>literal<\/code> elements to something more specific. For example, you define a list of commands that appear in your book and wrap each one in a <code>command<\/code> element. Creating explicit lists of commands, GUI buttons, and so on is tedious, but it&#8217;s still better to do these substitutions in the script.<\/li>\n<\/ul>\n<p>Finally, there&#8217;s the issue of broken IDs and links. Currently, every one of your AuthorIT hyperlinks is now a <code>ulink<\/code> that falls into one of these categories:<\/p>\n<ul>\n<li>The <code>ulink<\/code>&#8216;s <code>url<\/code> starts with &#8220;<code>mailto:<\/code>&#8220;. Convert these to <code>email<\/code> elements.<\/li>\n<li>The <code>ulink<\/code>&#8216;s <code>url<\/code> starts with &#8220;<code>http:\/\/<\/code>&#8220;, or &#8220;<code>ftp:\/\/<\/code>&#8220;, or &#8220;<code>gopher:\/\/<\/code>&#8220;. Leave these alone.<\/li>\n<li>The <code>ulink<\/code>&#8216;s <code>url<\/code> points to something like &#8220;<code>D1228.xml<\/code>&#8220;, a.k.a. nowhere. These are your former internal hyperlinks. They&#8217;re all broken.<\/li>\n<\/ul>\n<p>But don&#8217;t be discouraged, your script can actually &#8220;guess&#8221; at where many of these links should point. If a given internal <code>ulink<\/code> contains something like, &#8220;Configuring the MIRV Launch Sequence&#8221;, there&#8217;s an <em>excellent<\/em> chance that somewhere else in your document there&#8217;s a <code>section<\/code> with a <code>title<\/code>, &#8220;Configuring the MIRV Launch Sequence&#8221;! So all you have to do is:<\/p>\n<ol>\n<li>Convert the content of each <code>ulink<\/code> to a nicely-formatted ID. Replace whitespace with underscores, remove extraneous punctuation, and lower-casing everything.<\/li>\n<li>Convert the <code>ulink<\/code> to an <code>xref<\/code>, setting the <code>linkend<\/code> to the new ID.<\/li>\n<li>For each <code>section<\/code> element, apply the same ID-conversion algorithm to the <code>section<\/code>&#8216;s <code>title<\/code>. Set this value as the <code>section<\/code>&#8216;s <code>id<\/code>.<\/li>\n<\/ol>\n<p>A healthy fraction of your <code>id<\/code>s and <code>linkend<\/code>s should now match up, fixing those broken links.<\/p>\n<\/li>\n<li>\n<p><strong>Clean up the DocBook output manually.<\/strong><\/p>\n<p>Oh, you&#8217;re not done yet! Here&#8217;s a non-exhaustive list of what&#8217;s left:<\/p>\n<ul>\n<li>Fix the remaining invalid <code>id<\/code>s and broken links that your script didn&#8217;t catch.<\/li>\n<li>Fix any other DocBook validity issues.<\/li>\n<li>Add <code>programlisting<\/code> and <code>screen<\/code> elements where appropriate. Remove excess carriage returns as necessary.<\/li>\n<li>Make your inline markup consistent. For example, all command-line tools should be consistently marked up as <code>command<\/code>s (assuming your organization chooses to use that element). You can partly script this, but mostly this is a manual job.<\/li>\n<li>Remove any mysterious duplicate <code>section<\/code>s.<\/li>\n<li>Rename your images from &#8220;<code>898.png<\/code>&#8221; to something more descriptive, such as &#8220;<code>mirv_reentry_trajectory.png<\/code>&#8220;. Embed the images in a <code>figure<\/code> with a proper <code>title<\/code> and <code>id<\/code>.<\/li>\n<li>Add any missing front matter.<\/li>\n<li>Rebuild your index by hand. By <em>hand<\/em>. Jesus H. Christ.<\/li>\n<\/ul>\n<p>Now put your feet up on the desk and pour yourself a well-deserved gin-and-tonic. If anyone asks you why you look so frazzled, do <em>not<\/em> under any circumstances tell the truth. Otherwise they&#8217;ll just respond with, &#8220;Well, why don&#8217;t you just move it all to the corporate wiki?&#8221; And there&#8217;s only one rational reaction to <em>that<\/em>. Don&#8217;t get me wrong, it&#8217;s not easy to inflict serious blunt force trauma using a 15&#8243; Powerbook, but somehow, you&#8217;ll find a way.<\/p>\n<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Congratulations, your document is now DocBook! Well, more accurately, it&#8217;s &#8220;DocBook&#8221;. Just be happy your tables made it through, sort of.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,2],"tags":[],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-howto","category-tech"],"_links":{"self":[{"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/posts\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/comments?post=314"}],"version-history":[{"count":0,"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/posts\/314\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/media?parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/categories?post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.goer.org\/Journal\/wp-json\/wp\/v2\/tags?post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}