Commit 6a3bb8f6edbdcb780bcce96fee7cf33c0787a8af
1 parent
047d9221
Exists in
master
and in
112 other branches
DomDocument, simple_xml nas no xml:id attribute
Showing
1 changed file
with
27 additions
and
21 deletions
Show diff stats
php/makeOrbitsInKm.php
... | ... | @@ -65,28 +65,34 @@ |
65 | 65 | |
66 | 66 | $newId = $id."_km"; |
67 | 67 | $new_param_file = $amdaParamDir."/".$newId.".xml"; |
68 | - $newXML = new SimpleXMLElement("<param></param>"); | |
69 | - $newXML->addAttribute('xml:id', $newId); | |
70 | - $newInfo = $newXML->addChild('info'); | |
71 | - $newInfo->addChild('name', $paramXml->info->name); | |
72 | - $newInfo->addChild('short_name', $paramXml->info->name); | |
73 | - $newInfo->addChild('components', $paramXml->info->components); | |
74 | - $newInfo->addChild('units', 'km'); | |
75 | - $newInfo->addChild('coordinates_system', $paramXml->info->coordinates_system); | |
76 | - $newInfo->addChild('tensor_order', $paramXml->info->tensor_order); | |
77 | - $newInfo->addChild('si_conversion', 1.e3); | |
68 | + $newDom = new DomDocument("1.0"); | |
69 | + $newXML = $newDom->createElement("param"); | |
70 | + $newDom->appendChild($newXML); | |
71 | + $newXML->setAttribute("xml:id", $newId); | |
72 | + $newInfo = $newDom->createElement('info'); | |
73 | + $newInfo->appendChild($newDom->createElement('name', $paramXml->info->name)); | |
74 | + $newInfo->appendChild($newDom->createElement('short_name', $paramXml->info->name)); | |
75 | + $newInfo->appendChild($newDom->createElement('components', $paramXml->info->components)); | |
76 | + $newInfo->appendChild($newDom->createElement('units', 'km')); | |
77 | + $newInfo->appendChild($newDom->createElement('coordinates_system', $paramXml->info->coordinates_system)); | |
78 | + $newInfo->appendChild($newDom->createElement('tensor_order', $paramXml->info->tensor_order)); | |
79 | + $newInfo->appendChild($newDom->createElement('si_conversion', 1.e3)); | |
78 | 80 | //TODO scale fill value |
79 | - $newInfo->addChild('fill_value', $paramXml->info->fill_value); | |
80 | - $newInfo->addChild('ucd', $paramXml->info->ucd); | |
81 | - $newInfo->addChild('dataset_id', $paramXml->info->dataset_id); | |
82 | - $newGet = $newXML->addChild('get'); | |
83 | - $newVi = $newGet->addChild('vi'); | |
84 | - $newVi->addAttribute('name', $paramXml->get->vi['name']); | |
85 | - $newParam = $newVi->addChild('baseParam'); | |
86 | - $newParam->addAttribute('name', $paramXml->get->vi->baseParam['name']); | |
87 | - $newXML->addChild('process',$newProcess); | |
88 | - $newXML->addChild('output'); | |
89 | - $newXML->asXML($new_param_file); | |
81 | + $newInfo->appendChild($newDom->createElement('fill_value', $paramXml->info->fill_value)); | |
82 | + $newInfo->appendChild($newDom->createElement('ucd', $paramXml->info->ucd)); | |
83 | + $newInfo->appendChild($newDom->createElement('dataset_id', $paramXml->info->dataset_id)); | |
84 | + $newXML->appendChild($newInfo); | |
85 | + $newGet = $newDom->createElement('get'); | |
86 | + $newXML->appendChild($newGet); | |
87 | + $newVi = $newDom->createElement('vi'); | |
88 | + $newVi->setAttribute('name', $paramXml->get->vi['name']); | |
89 | + $newGet->appendChild($newVi); | |
90 | + $newParam = $newDom->createElement('baseParam'); | |
91 | + $newParam->setAttribute('name', $paramXml->get->vi->baseParam['name']); | |
92 | + $newVi->appendChild($newParam); | |
93 | + $newXML->appendChild($newDom->createElement('process',$newProcess)); | |
94 | + $newXML->appendChild($newDom->createElement('output')); | |
95 | + $newDom->save($new_param_file); | |
90 | 96 | |
91 | 97 | $newOrbit = $domKm->createElement('orbites'); |
92 | 98 | $newOrbit->setAttribute('xml:id', $newId); |
... | ... |