/** * Construct the whole DCAT-AP document given an array of dump info * * @param array $data data-blob of i18n and config variables * @return string: xmldata */ function outputXml(array $data) { // Initializing the XML Object $xml = new XmlWriter(); $xml->openMemory(); $xml->setIndent(true); $xml->setIndentString(' '); // set namespaces $xml->startDocument('1.0', 'UTF-8'); $xml->startElementNS('rdf', 'RDF', null); $xml->writeAttributeNS('xmlns', 'rdf', null, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'); $xml->writeAttributeNS('xmlns', 'dcterms', null, 'http://purl.org/dc/terms/'); $xml->writeAttributeNS('xmlns', 'dcat', null, 'http://www.w3.org/ns/dcat#'); $xml->writeAttributeNS('xmlns', 'foaf', null, 'http://xmlns.com/foaf/0.1/'); $xml->writeAttributeNS('xmlns', 'adms', null, 'http://www.w3.org/ns/adms#'); $xml->writeAttributeNS('xmlns', 'vcard', null, 'http://www.w3.org/2006/vcard/ns#'); // Calls previously declared functions to construct xml writePublisher($xml, $data); writeContactPoint($xml, $data); $dataset = array(); // Live dataset and distributions $liveDistribs = writeDistribution($xml, $data, 'ld', null); if ($data['config']['api-enabled']) { $liveDistribs = array_merge($liveDistribs, writeDistribution($xml, $data, 'api', null)); } array_push($dataset, writeDataset($xml, $data, null, $liveDistribs)); // Dump dataset and distributions if ($data['config']['dumps-enabled']) { foreach ($data['dumps'] as $key => $value) { $distIds = writeDistribution($xml, $data, 'dump', $key); array_push($dataset, writeDataset($xml, $data, $key, $distIds)); } } writeCatalog($xml, $data, $dataset); // Closing last XML node $xml->endElement(); // Printing the XML return $xml->outputMemory(true); }
/** * Generates the atom XML properties. * * @param \XmlWriter $xmlw The XML writer. * @param array $properties The atom properties. * * @return none */ private function _generateProperties($xmlw, $properties) { foreach ($properties as $key => $value) { $content = key($value); $attributes = $value[$content]; $xmlw->startElementNS($this->_dataServicesPrefix, $key, null); if (!is_null($attributes)) { foreach ($attributes as $attribute => $attributeValue) { $xmlw->writeAttributeNS($this->_dataServicesMetadataPrefix, $attribute, null, $attributeValue); } } $xmlw->text($content); $xmlw->endElement(); } }