From 5656c46bfdb7082fa4c31c3a4e1ba965c797fda0 Mon Sep 17 00:00:00 2001 From: Nathanaƫl Jourdane Date: Mon, 9 Apr 2018 17:25:20 +0200 Subject: [PATCH] Check for id on each node. --- update_amda/makeTree.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/update_amda/makeTree.php b/update_amda/makeTree.php index 657ccc8..336da30 100644 --- a/update_amda/makeTree.php +++ b/update_amda/makeTree.php @@ -55,6 +55,7 @@ { foreach ($observatories as $obs) { + echo $obs->getAttribute('xml:id') . PHP_EOL; if ($obs->hasAttribute('target')) { $target = $obs->getAttribute('target'); @@ -77,16 +78,21 @@ // check ID duplication $allIds = array(); - foreach($localDom->getElementsByTagName('*') as $element) - { - $allIds[] = $element->getAttribute('xml:id'); + /** @var DOMElement $element */ +foreach($localDom->getElementsByTagName('*') as $element) + { + $id = $element->getAttribute('xml:id'); + $allIds[] = $id; + if (!$id) { + echo 'No id in node ' . $element->tagName . PHP_EOL; + } } $arr = array_count_values($allIds); - print_r('DUPLICATED IDs : '.PHP_EOL); - foreach ($arr as $key => $value) - if ($value > 1) print_r($key.'=>'.$value.PHP_EOL); - + foreach ($arr as $key => $value) { + if ($value > 1) print_r("id '$key' is duplicated $value times." . PHP_EOL); + } + // set 'TBD' attribute - if the parameter is not checked yet if (is_dir(TBD)) { -- libgit2 0.21.2