2
# vi:si:et:sw=4:sts=4:ts=4
5
Convert a C program to valid XML to be included in docbook
10
from xml.sax import saxutils
13
if len(sys.argv) == 1:
14
sys.stderr.write("Please specify a source file to convert")
18
if not os.path.exists(source):
19
sys.stderr.write("%s does not exist.\n" % source)
22
content = open(source, "r").read()
25
print '<?xml version="1.0"?>'
26
print '<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">'
28
print '<programlisting>'
31
print saxutils.escape(content).encode('UTF-8')
32
print '</programlisting>'