> [B] OR Use XIncludes ?and in such case, the included file (e.g. a
> refentry) must really start with the proper <!DOCTYPE> (e.g. <!DOCTYPE
> refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
> "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd";>)

>
> Therefore, now that we know that you use XIncludes, we really recommend
> that you write and run this Perl script in order to add the proper
> <!DOCTYPE> to your numerous XML files.

Feeling somewhat daring, I found that the following bash commands did the trick:

(1) MAKE .. A .. BACKUP .. OF .. THE .. DIRECTORY .. AND .. ..

(2)
doctype='<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML
V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd";>'
 for file in *.xml; do sed -i "2i$doctype" "$file"; done

This technique, while not =generally= applicable, was sufficient in
this case.  It uses the "-i" (in-place) option of the "sed" (stream
editor) command that standard-equipment in Unix/Linux environments.
The command inserts the specified DOCTYPE declaration as the second
line of all files in the directory.  (I had already verified that none
of them contained a "doctype.")  In this way, hundreds of files were
identically processed in a couple of seconds.

Again:  this is "for one's edification and amusement only."  "Do not
try this at home."  But in my specific case it did work well and let
me avoid writing a Perl script altogether.

Reply via email to