This example converts an RMF file to xml, in order to display it in an XML viewer such as firefox. Its functionality is largely identical to the rmf_xml
program. The secondary purpose it to provide an example of extracting all data from an RMF file and converting it to some other source. The data extracted here is completely uninterpreted (eg, cartesian coordinates are treated just the same as other values). See the source code of rmf_xml for a similar example in C++.
14 file_name = RMF.get_example_path(
"simple.rmf3")
20 def show_data_xml(nh, kc):
23 keys = rh.get_keys(kc)
29 print(
"<", rh.get_name(kc))
32 name.replace(
" ",
"_")
33 print(name,
"=\"" + str(v) +
"\"")
38 def show_xml(nh, kcs):
40 name.replace(
" ",
"_")
41 print(
"<node name=\"" + name +
"\" id=\"" + str(nh.get_id().get_index())\
42 +
"\" type=\"" + str(nh.get_type()) +
"\"/>")
46 children = nh.get_children()
55 print(
"<?xml version=\"1.0\"?>")
60 print(
"<description>")
61 print(rh.get_description())
62 print(
"</description>")
66 kcs = rh.get_categories()
67 show_xml(rh.get_root_node(), kcs)