treeview.cgi

#!/usr/bin/python

# This cgi script is used to display the central ceXML xml file
# containing all the builtobjects, quantifications, languages,
# etcetera. Also, some small editing possibilities are available.

import cgi
import os
import cexmlhelper

# Read in the parameters passed to this script using the CGI POST
# method 
form = cgi.FieldStorage()
try: 
    selected_language = form["selectedlanguage"].value
except:
    selected_language = "en"
try:
    selected_name = form["selectedname"].value
except:
    selected_name = "beam"
try:
    mode = form["mode"].value
except:
    mode = "normal"
try:
    new_name = form["newname"].value
except:
    new_name = "test"
try:
    edit_language = form["editlanguage"].value
except:
    edit_language = "en"

# Set the classpath
cexmlhelper.set_linux_classpath()
# First, propagate all characteristics of the parents over all the
# children 
temporary_file = cexmlhelper.process_with_xslt("cexml.xml",
                                               "propagate.xslt")
# Then, re-join the complete function, unit and quantification info
# with the builtobject tree
temporary_file = cexmlhelper.process_with_xslt(temporary_file,
                                               "rejoin.xslt")
# Next, strip out the un-needed languages
temporary_file = cexmlhelper.process_with_xslt(temporary_file,
                                               "language-.xslt",
                                               [("selectedlanguage",
                                                 "\"'%s'\"" %
                                                 selected_language)] )
# Finally, prepare the info for visualisation
temporary_file = cexmlhelper.process_with_xslt(temporary_file,
                                               "builtobject_tree.xslt",
                                               [("selectedname",
                                                 "\"'%s'\"" %
                                                 selected_name), 
                                                ("selectedlanguage",
                                                 "\"'%s'\"" %
                                                 selected_language)] )  
cexmlhelper.print_xml_file(temporary_file)
cexmlhelper.remove_temporary_files()