from lxml import etree
import sys, os

def generate_DOT(xmlName):
	xsl_tree = etree.parse('./xslt/toDot.xsl')
	transform = etree.XSLT(xsl_tree)
	doc = etree.parse(xmlName)
	result = transform(doc)
	out = open(xmlName[:xmlName.find('.xml')] + '.dot', 'w')
	out.write(str(result))
	out.close()
	# call the DOT software now
	os.system("dot -Tpng -o" + xmlName[:xmlName.find('.xml')] + '.png' + " " + xmlName[:xmlName.find('.xml')] + '.dot')

if __name__ == '__main__':
	generate_DOT(sys.argv[1])
