function mds_put_dc_elements($mdo, $dcelem) { if (($mdt = $this->mds_get($mdo->mdo_eid)) === FALSE) { $mdt = $mdo->mdo_generate_default_xml_metadata(); $exists = FALSE; } else $exists = TRUE; $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE; foreach ($dcelem as $dce => $value) { $xmlDoc->xmd_update($mdo->mdo_dcmap_v[$dce], (string) $value); } $this->mds_put($mdo->mdo_eid, '', 'md5', $exists); return $this->mds_put($mdo->mdo_eid, $xmlDoc->xmd_xml()); }
$langMdCopyright = 'Ghent University'; foreach (array(1001, 1002, 1003) as $eid_id) { $mdObj = new mdobject($_course, $eid_id); // see 'md_' . EID_TYPE . '.php' $eid = $mdObj->mdo_eid; $titlePath = $mdObj->mdo_dcmap_v['Title']; // no IEEE dependencies here... if (($mdt_rec = $mdStore->mds_get($eid)) === FALSE) { $mdt = $mdObj->mdo_generate_default_xml_metadata(); $xmlDoc = new xmddoc(explode("\n", $mdt)); if (!$xmlDoc->error) { echo htmlspecialchars($titlePath), ': '; $mdTitle = $xmlDoc->xmd_value($titlePath); if ($mdTitle == $langMdTitle) { $mdTitle = EID_TYPE . ' ' . $eid_id; $xmlDoc->xmd_update($titlePath, $mdTitle); $mdt = $xmlDoc->xmd_xml(); } echo htmlspecialchars($mdTitle), ':'; } $mdStore->mds_put($eid, $mdt, 'mdxmltext', FALSE); echo '<a href="../index.php?eid=', urlencode($eid), '">', htmlspecialchars($eid), '</a><br>'; } } echo '<br>'; $xmlDoc = new xmddoc(explode("\n", $mdStore->mds_get($eid = EID_TYPE . '.1002'))); if ($xmlDoc->error) { give_up($xmlDoc->error); } $mdObj = new mdobject($_course, '1002'); $mda = "~~";
showDoc('Attributes with namespaces added, ns def is auto-generated'); $stuff = 'subtag => ' . $testdoc->xmd_get_ns_uri($subtag) . "\n"; foreach ($testdoc->attributes[$sometag1] as $name => $value) { $stuff .= $name . ' => ' . $testdoc->xmd_get_ns_uri($sometag1, $name) . "\n"; } showDoc('Namespace-URI of subtag, of 1st sometag attributes', $stuff); $subsub = $testdoc->xmd_add_element('urn:sample-default:subsub', $subtag, array('xmlns' => 'urn:sample-default', 'someatt' => 'somevalue')); $subsubsub = $testdoc->xmd_add_element('urn:sample-default:subsubsub', $subsub); showDoc('Subsub element has default namespace'); $stuff = 'subsub => ' . $testdoc->xmd_get_ns_uri($subsub) . "\n"; $stuff .= 'subsubsub => ' . $testdoc->xmd_get_ns_uri($subsubsub) . "\n"; foreach ($testdoc->attributes[$subsub] as $name => $value) { $stuff .= $name . ' => ' . $testdoc->xmd_get_ns_uri($subsub, $name) . "\n"; } showDoc('Namespace-URI of subsub and subsubsub; attributes have none', $stuff); $testdoc->xmd_update('!newtag', 'text for newtag'); showDoc("After update '!newtag', 'text for newtag'"); $testdoc->xmd_update('newtag', 'new text for newtag'); showDoc("After update 'newtag', 'new text for newtag'"); $testdoc->xmd_update('newtag/@someatt', 'attval'); showDoc("After update 'newtag/@someatt', 'attval'"); $testdoc->xmd_update('newtag/~', ''); showDoc("After update 'newtag/~', ''"); $keepdoc = $testdoc; $wrongdoc = "<html>\n <body>\n <p>Text</p>\n <p>More text" . "\n </body>\n</html>"; $testdoc = new xmddoc(explode("\n", $wrongdoc)); showDoc('Xml doc with syntax error + error message', $wrongdoc . "\n\n" . $testdoc->error); $xmlFile = 'imsmanifest_reload.xml'; $presXmlFileContents = @file_get_contents_n($xmlFile) or die('XML file ' . htmlspecialchars($xmlFile) . ' is missing...'); showDoc('XML file to be parsed', $presXmlFileContents); $testdoc = new xmddoc(explode("\n", $presXmlFileContents));