Friends,

I am working a project where I need to generate documents from DocBook/XML (xsl) to mulitple formats. I discovered that on Linux, at least, I can use docbook2* (i.e. docbook2html and docbook2rtf), but these commands only take DocBook/SGML (DTD) files as input. I changed one of the DocBook/XML files to a DocBook/SGML by hand and here is the pertinent sdiff ...
<?xml version="1.0"?> | <!DOCT +YPE book PUBLIC "-//OASIS//DTD DocBook V4.2//EN" [ <!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//E | <!ENTI +TY nwalsh "Norman Walsh"> "/usr/share/sgml/docbook/xml-dtd-4.2-1.0-17/docbookx.dtd"> | ]> <article> | <book> <articleinfo> | + <bookinfo> <title>sudo Use and Administration on RH9</ti + <title>sudo Use and Administration on RH9</ti </articleinfo> | + </bookinfo> > <artic +le> <sect1> <title>Introduction</title> <para> + <sect1> <title>Introduction</title> <para> This document describes how to use and administor sudo on RH9 This d +ocument describes how to use and administor sudo on RH9 </para><para> + </para><para> blah blah ... </sect1> + </sect1> </article> </arti +cle> > </book +>
... I know that looks like hell in code tags but I hope it looks better if you click dl/code link :)

I have a ton of these docs to do this too, so hand editting all of them is out of the question. My question is, "Is there some cool XML/XSLT/DTD/something-or-other Perl module I could use to make these changes for me or will I have to "roll-my-own" translator?". You know something awful and buggy like ...
#!/usr/bin/perl -w use strict; my $DTD_VER = "4.2" + + my $firstLine = <>; + + print $firstLine if $firstLine !~ /^\<\?xml/; while(<>) { s/artlicle/book/g; s/DocBook XML V\d\.\d\.\d/DocBook V$DTD_VER/g; ... print $_; } print "</book>\n";

You would think with all the XML hype somebody has done this before or am I just barking up the wrong tree here?

Plankton: 1% Evil, 99% Hot Gas.

In reply to XML to SGML or xsl vs DTD confused by Plankton

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.