C++ code generation from xml

Max Ischenko max at malva.com.uaREMOVE.IT
Mon Apr 15 04:03:04 EDT 2002


Hi there.

I have a Python program that uses data stored in XML file to generate some
C++ code. The problem (or, more precisely, code smell) I have is that the
actual generation algorithm is hardwired into python and therefore is
cryptic, difficult to understand and maintain.

Small example:
	def genBody(self, c):
		name = c.cxxClassName
		new = 'new %s(%s);' % (name, c.factoryCtorArg or '')
		if c.factoryNargs == 0:
			return '\treturn %s' % new
		body = '\t%s * c = %s\n' % (name, new)
		body = body + '\tc->setCmdArgs(args);\n'
		return '%s\treturn c;' % body

I'd like to have the algorithm moved out from Python source.
I've heard about XSLT language that is used to describe transformation of
XML data into HTML. I'm seeking for something similar. The difference is
that target language is C++ and not HTML.

Any suggestions?

Thanks in advance.


-- 
"We all know Linux is great...it does infinite loops in 5 seconds."
(Linus Torvalds about the superiority of Linux on the Amterdam
Linux Symposium)



More information about the Python-list mailing list