Esempio n. 1
0
function check_andor_get($row, $get = '', $check = '', $tobe = '')
{
	global $mdCat, $htmldecode;

	if (!$check && !$get) return FALSE;

	$regs = array(); // for use with ereg()

	if ($get == $mdCat && !$check)  // cheat to be quicker
		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>',
			$row['mdxmltext'], $regs)) return strtr($regs[1], $htmldecode);

	if ($check == $mdCat && !$get)  // cheat to be quicker
		if (ereg('<coverage>[^<]*<string language="..">([^<]+)<\/string>',
			$row['mdxmltext'], $regs))
				return (strtr($regs[1], $htmldecode) == $tobe);

	$xmlDoc = new xmddoc(explode("\n", $row['mdxmltext']));
	if ($xmlDoc->error) return FALSE;

	if (!$check) return $xmlDoc->xmd_value($get);

	if ($xmlDoc->xmd_value($check) == $tobe)
		return $get ? $xmlDoc->xmd_value($get) : TRUE;

	return FALSE;
}
Esempio n. 2
0
$langMdTitle = 'Default Title (if doc not in DB)';
$langMdDescription = 'Default description (if doc has no comment)';
$langMdCoverage = 'bachelor of engineering';
$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);
Esempio n. 3
0
 function mds_get_dc_elements($mdo)  // no record: FALSE
 {
     if (!($mdt = $this->mds_get($mdo->mdo_eid))) return FALSE;    
     $xmlDoc = new xmddoc(explode("\n", $mdt)); if ($xmlDoc->error) return FALSE;    
     $result = array();
     foreach ($mdo->mdo_dcmap_v as $dce => $xp) {
         $result[$dce] = $xmlDoc->xmd_value($xp);
     }    
     return $result;
 }
Esempio n. 4
0
$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));
unset($presXmlFileContents);
if ($testdoc->error) {
    die($xmlFile . ':<br><br>' . $testdoc->error);
}
$testdoc->xmd_update_many('metadata/lom/general/title,metadata/lom/general/description', 'langstring/@lang', 'fr');
$testdoc->xmd_copy_foreign_child($keepdoc, $keepdoc->xmd_select_single_element('sometag[2]'));
showDoc('After parsing, and after changing 2* langstring/@lang to fr, ' . 'and after adding a foreign doc, reconstruction from memory');
showDoc('Element tagname of first metadata/lom/* element', $testdoc->name[$testdoc->xmd_select_single_element('metadata/lom/*')]);
showDoc('Element namespace URI of metadata/lom/*[2]', $testdoc->xmd_get_ns_uri($testdoc->xmd_select_single_element('metadata/lom/*[2]')));
showDoc('Number of metadata/lom/* elements', count($testdoc->xmd_select_elements('metadata/lom/*')));
showDoc('Number of resources/resource/file elements with @href', count($testdoc->xmd_select_elements_where_notempty('resources/resource/file', '@href')));
$elems = $testdoc->xmd_select_elements_where('resources/resource', 'file[1]/@href', 'three.html');
showDoc('Resource identifier where file[1]/@href is three.html', $testdoc->xmd_value('@identifier', $elems[0]));
$elems = $testdoc->xmd_select_elements_where('resources/resource', '@identifier', $testdoc->xmd_value('organizations/organization/item[2]/@identifierref'));
showDoc('Resource href for item[2]', $testdoc->xmd_value('@href', $elems[0]));
$stuff = '';
foreach (array('@identifier', 'metadata/schema', '*/*/*/*[1]/langstring', 'resources/resource[3]/@href', 'resources/resource[3]/file/@href', 'resources/resource[3]/@*', 'resources/resource[3]/-/@href', 'resources/resource[3]/+/@href', 'resources/resource[1]/-/@href', 'resources/../../../../../../../@identifier', '@*', 'resources/@*', 'organizations/organization/item[4]/title', 'organizations/organization/item[-2]/title', 'organizations/organization/item[4]/@*', 'organizations/organization/item[4]/@*item', 'organizations/organization/item[2]/+item/title', 'organizations/organization/item[2]/+/+/+/title', 'organizations/organization/item[2]/-item', 'organizations/organization/item[1]/-item', 'organizations/organization/item[1]/-', 'organizations/organization/item[1]/-/@.') as $path) {
    $stuff .= $path . ' => ' . $testdoc->xmd_value($path) . "\n";
}
showDoc('Values of: @identifier, metadata/schema, ... (see below)', $stuff);
function showHtml($path)
{
    global $testdoc;
    echo '<h4>Html-value of ', htmlspecialchars($path), '</h4><pre>', $testdoc->xmd_html_value($path), '</pre>';
}
showHtml('/*/organizations/organization/item[1]/title');
showHtml('organizations/organization/item/title');
showHtml('organizations/organization/item/title *');