Commit 5656c46bfdb7082fa4c31c3a4e1ba965c797fda0
1 parent
86c90e3a
Exists in
master
and in
109 other branches
Check for id on each node.
Showing
1 changed file
with
13 additions
and
7 deletions
Show diff stats
update_amda/makeTree.php
... | ... | @@ -55,6 +55,7 @@ |
55 | 55 | { |
56 | 56 | foreach ($observatories as $obs) |
57 | 57 | { |
58 | + echo $obs->getAttribute('xml:id') . PHP_EOL; | |
58 | 59 | if ($obs->hasAttribute('target')) |
59 | 60 | { |
60 | 61 | $target = $obs->getAttribute('target'); |
... | ... | @@ -77,16 +78,21 @@ |
77 | 78 | |
78 | 79 | // check ID duplication |
79 | 80 | $allIds = array(); |
80 | - foreach($localDom->getElementsByTagName('*') as $element) | |
81 | - { | |
82 | - $allIds[] = $element->getAttribute('xml:id'); | |
81 | + /** @var DOMElement $element */ | |
82 | +foreach($localDom->getElementsByTagName('*') as $element) | |
83 | + { | |
84 | + $id = $element->getAttribute('xml:id'); | |
85 | + $allIds[] = $id; | |
86 | + if (!$id) { | |
87 | + echo 'No id in node ' . $element->tagName . PHP_EOL; | |
88 | + } | |
83 | 89 | } |
84 | 90 | $arr = array_count_values($allIds); |
85 | 91 | |
86 | - print_r('DUPLICATED IDs : '.PHP_EOL); | |
87 | - foreach ($arr as $key => $value) | |
88 | - if ($value > 1) print_r($key.'=>'.$value.PHP_EOL); | |
89 | - | |
92 | + foreach ($arr as $key => $value) { | |
93 | + if ($value > 1) print_r("id '$key' is duplicated $value times." . PHP_EOL); | |
94 | + } | |
95 | + | |
90 | 96 | // set 'TBD' attribute - if the parameter is not checked yet |
91 | 97 | if (is_dir(TBD)) |
92 | 98 | { | ... | ... |