20 function toXml($dataObject, $format =
null) {
21 import(
'plugins.metadata.dc11.schema.Dc11Schema');
22 $dcDescription = $dataObject->extractMetadata(
new Dc11Schema());
24 $response =
"<oai_dc:dc\n" .
25 "\txmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\"\n" .
26 "\txmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" .
27 "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" .
28 "\txsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/\n" .
29 "\thttp://www.openarchives.org/OAI/2.0/oai_dc.xsd\">\n";
31 foreach($dcDescription->getProperties() as $propertyName => $property) {
32 if ($dcDescription->hasStatement($propertyName)) {
33 if ($property->getTranslated()) {
34 $values = $dcDescription->getStatementTranslations($propertyName);
36 $values = $dcDescription->getStatement($propertyName);
38 $response .= $this->
formatElement($propertyName, $values, $property->getTranslated());
42 $response .=
"</oai_dc:dc>\n";
54 if (!is_array($values)) $values = array($values);
57 $openingElement = str_replace(array(
'[@',
']'), array(
' ',
''), $propertyName);
62 foreach ($values as $key => $value) {
64 $key = str_replace(
'_',
'-', $key);
65 assert(is_array($value));
66 foreach ($value as $subValue) {
67 if ($key == METADATA_DESCRIPTION_UNKNOWN_LOCALE) {
70 $response .=
"\t<$openingElement xml:lang=\"$key\">" .
OAIUtils::prepOutput($subValue) .
"</$closingElement>\n";
74 assert(is_scalar($value));