Browse Source

xml namespaces

Florian 4 years ago
parent
commit
0b61f31cb5
1 changed files with 6 additions and 0 deletions
  1. 6 0
      signals_gen.py

+ 6 - 0
signals_gen.py

@@ -22,6 +22,8 @@ def make_subelement(parent_node, sub_name, sub_attrs=None):
 def make_signal_systems(network_root, signals):
     ''' make signal systems xml root '''
     signal_systems = etree.Element('signalSystems')
+    signal_systems.set('xmlns', 'http://www.matsim.org/files/dtd')
+    signal_systems.set('{http://www.w3.org/2001/XMLSchema-instance}schemaLocation', 'http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/signalSystems_v2.0.xsd')
     for n_sig, sig in enumerate(signals):
         sig_node_id = sig.get('id')
         links = network_root.xpath("/network/links/link[@to='{}']".format(sig_node_id))
@@ -35,6 +37,8 @@ def make_signal_systems(network_root, signals):
 def make_signal_groups(signal_systems):
     ''' make signal groups xml root '''
     signal_groups = etree.Element('signalGroups')
+    signal_groups.set('xmlns', 'http://www.matsim.org/files/dtd')
+    signal_groups.set('{http://www.w3.org/2001/XMLSchema-instance}schemaLocation', 'http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/signalGroups_v2.0.xsd')
     for n_sig_sys, sig_sys in enumerate(signal_systems.xpath('/signalSystems/signalSystem')):
         signal_system = make_subelement(signal_groups, 'signalSystem', {'refId': sig_sys.get('id')})
         for n_sig, sig in enumerate(sig_sys.xpath('signals/signal')):
@@ -45,6 +49,8 @@ def make_signal_groups(signal_systems):
 def make_signal_control(signal_systems, signal_groups):
     ''' make signal control xml root '''
     signal_control = etree.Element('signalControl')
+    signal_control.set('xmlns', 'http://www.matsim.org/files/dtd')
+    signal_control.set('{http://www.w3.org/2001/XMLSchema-instance}schemaLocation', 'http://www.matsim.org/files/dtd http://www.matsim.org/files/dtd/signalControl_v2.0.xsd')
     for sig_sys in signal_systems.xpath('/signalSystems/signalSystem'):
         sig_sys_id = sig_sys.get('id')
         signal_system = make_subelement(signal_control, 'signalSystem', {'refId': sig_sys_id})