18 """ Generates the representation of the file designed by filename
19 in memory. Build a tree.
21 :param filename: name of the file to parse
22 :returns: the tree representing the file
24 parser = xml.sax.make_parser()
26 parser.setContentHandler(handler)
27 parser.parse(open(filename))
29 root_node = handler.get_root()
30 if root_node.format_version !=
"4":
37 """ ContentHandler to parse the xar file
41 xml.sax.handler.ContentHandler.__init__(self)
48 if name ==
'ChoregrapheProject':
49 new_node = node_choregraphe_project.ChoregrapheProject(
51 elif name ==
'BoxInstance':
52 new_node = node_box_instance.BoxInstance(
54 elif name ==
'ParameterValue':
55 new_node = node_parameter_value.ParameterValue(
57 elif name ==
'PluginContent':
58 new_node = node_plugin_content.PluginContent(
65 parent_node = self.
_nodes.pop()
66 parent_node.attach_attribute(name, new_node)
67 parent_node.add_child(new_node)
68 self.
_nodes.append(parent_node)
70 self.
_nodes.append(new_node)
72 """ pluginContent beacon can embed anything, raw string as well as
75 new_node = node_plugin_content.PluginSubNode(name, attrs)
76 parent_node = self.
_nodes.pop()
77 parent_node.add_subnode(new_node)
78 parent_node.add_child(new_node)
79 self.
_nodes.append(parent_node)
80 self.
_nodes.append(new_node)
85 if (name ==
'BoxInstance'
86 or name ==
'ChoregrapheProject'
87 or name ==
'ParameterValue'
88 or name ==
'PluginContent'):
91 current_subnode = self.
_nodes.pop()
93 current_subnode.add_content(self.
_buffer)