Converting a document to XML cannot always be done automatically,
since there are some SGML constructs which do not map easily to XML
(for detailed discussions, see James Clark's W3C note on the differences between SGML and
XML, and Norm Walsh's notes on converting an
SGML DTD to XML, which covers some of the same issues).
However, you can get help with this using the program sgml2xml
,
which converts the body of a document to XML without difficulty, and
additionally attempts to convert the declaration subset (see
Section 3.3) by rewriting entities to conform to XML's more
straitened[Note 9] syntax, and rewriting SUBDOC
entities as
NDATA XML
ones. It can't do everything, however, and so spits
out warnings whenever it finds anything in the least problematic.
Use is simple:
See also the notes in the detailed documentation.sgml2xml myfile.sgml >myfile.xml