/** * Check if we need to generate or not concept identifiers (notation and uri). * Validates any existing identifiers. * @param DOMNode $Description * @param DOMDocument $doc * @return boolean If an uri must be autogenerated */ protected function checkConceptIdentifiers(DOMNode $Description, DOMDocument $doc) { // We return if an uri must be autogenerated $autoGenerateUri = false; $autoGenerateIdentifiers = filter_var($this->getRequest()->getParam('autoGenerateIdentifiers', false), FILTER_VALIDATE_BOOLEAN); $xpath = new DOMXPath($doc); $notationNodes = $xpath->query('skos:notation', $Description); $uri = $Description->getAttributeNS(OpenSKOS_Rdf_Parser::$namespaces['rdf'], 'about'); if ($autoGenerateIdentifiers) { if ($uri || $notationNodes->length > 0) { throw new Zend_Controller_Action_Exception('Parameter autoGenerateIdentifiers is set to true, but the xml already contains notation (skos:notation) and/or uri (rdf:about).', 400); } $autoGenerateUri = true; } else { // Is uri missing if (!$uri) { throw new Zend_Controller_Action_Exception('Uri (rdf:about) is missing from the xml. You may consider using autoGenerateIdentifiers.', 400); } // Is notation missing if ($notationNodes->length == 0) { throw new Zend_Controller_Action_Exception('Notation (skos:notation) is missing from the xml. You may consider using autoGenerateIdentifiers.', 400); } // Is uri based on notation if (!OpenSKOS_Db_Table_Notations::isContainedInUri($uri, $notationNodes->item(0)->nodeValue)) { throw new Zend_Controller_Action_Exception('The concept uri (rdf:about) must be based on notation (must contain the notation)', 400); } $autoGenerateUri = false; } return $autoGenerateUri; }