Skip to content

Commit

Permalink
Updated xml media-types and checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Berthereau authored and Daniel Berthereau committed Jan 3, 2022
1 parent 4f2aeda commit b9f9cae
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions application/src/File/TempFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,42 +84,43 @@ class TempFile
'http://www.w3.org/2005/Atom' => 'application/atom+xml',
'http://purl.org/rss/1.0/' => 'application/rss+xml',
// Common in library and culture world.
'http://bibnum.bnf.fr/ns/alto_prod' => 'application/vnd.alto+xml',
'http://bibnum.bnf.fr/ns/alto_prod' => 'application/alto+xml',
'http://bibnum.bnf.fr/ns/refNum' => 'application/vnd.bnf.refnum+xml',
'http://www.iccu.sbn.it/metaAG1.pdf' => 'application/vnd.iccu.mag+xml',
'http://www.loc.gov/MARC21/slim' => 'application/vnd.marc21+xml',
'http://www.loc.gov/METS/' => 'application/vnd.mets+xml',
'http://www.loc.gov/mods/' => 'application/vnd.mods+xml',
'http://www.loc.gov/standards/alto/ns-v3#' => 'application/vnd.alto+xml',
'http://www.loc.gov/MARC21/slim' => 'application/marcxml+xml',
'http://www.loc.gov/METS/' => 'application/mets+xml',
'http://www.loc.gov/mods/' => 'application/mods+xml',
'http://www.loc.gov/standards/alto/ns-v3#' => 'application/alto+xml',
'http://www.music-encoding.org/ns/mei' => 'application/vnd.mei+xml',
'http://www.music-encoding.org/schema/3.0.0/mei-all.rng' => 'application/vnd.mei+xml',
// See https://github.com/w3c/musicxml/blob/gh-pages/schema/musicxml.xsd
'http://www.musicxml.org/xsd/MusicXML' => 'application/vnd.recordare.musicxml',
'http://www.musicxml.org/xsd/MusicXML' => 'application/vnd.recordare.musicxml+xml',
'http://www.openarchives.org/OAI/2.0/' => 'application/vnd.openarchives.oai-pmh+xml',
'http://www.openarchives.org/OAI/2.0/static-repository' => 'application/vnd.openarchives.oai-pmh+xml',
'http://www.tei-c.org/ns/1.0' => 'application/vnd.tei+xml',
'http://www.tei-c.org/ns/1.0' => 'application/tei+xml',
// Omeka should support itself.
'http://omeka.org/schemas/omeka-xml/v1' => 'text/vnd.omeka+xml',
'http://omeka.org/schemas/omeka-xml/v2' => 'text/vnd.omeka+xml',
'http://omeka.org/schemas/omeka-xml/v3' => 'text/vnd.omeka+xml',
'http://omeka.org/schemas/omeka-xml/v4' => 'text/vnd.omeka+xml',
'http://omeka.org/schemas/omeka-xml/v5' => 'text/vnd.omeka+xml',
// Doctype and root elements in case there is no namespace.
'alto' => 'application/vnd.alto+xml',
'alto' => 'application/alto+xml',
'ead' => 'application/vnd.ead+xml',
'feed' => 'application/atom+xml',
'html' => 'text/html',
'mag' => 'application/vnd.iccu.mag+xml',
'mei' => 'application/vnd.mei+xml',
'mets' => 'application/vnd.mets+xml',
'mods' => 'application/vnd.mods+xml',
'mets' => 'application/mets+xml',
'mods' => 'application/mods+xml',
'pdf2xml' => 'application/vnd.pdf2xml+xml',
'refNum' => 'application/vnd.bnf.refnum+xml',
'rss' => 'application/rss+xml',
'score-partwise' => 'application/vnd.recordare.musicxml',
'score-partwise' => 'application/vnd.recordare.musicxml+xml',
'svg' => 'image/svg+xml',
'TEI' => 'application/vnd.tei+xml',
'TEI' => 'application/tei+xml',
// 'collection' => 'application/vnd.marc21+xml',
'xhtml' => 'application/xhtml+xml',
];

/**
Expand Down Expand Up @@ -541,8 +542,13 @@ protected function getMediaTypeXml()
break;
}

// To be improved or skipped.
if ($reader->nodeType === XMLReader::PI
&& !in_array($reader->name, ['xml-stylesheet', 'oxygen'])
&& !in_array($reader->name, [
'xml-model',
'xml-stylesheet',
'oxygen',
])
) {
$matches = [];
if (preg_match('~href="(.+?)"~mi', $reader->value, $matches)) {
Expand Down Expand Up @@ -578,9 +584,7 @@ protected function getMediaTypeXml()
}
*/

return isset($this->xmlMediaTypes[$type])
? $this->xmlMediaTypes[$type]
: null;
return $this->mediaTypeIdentifiers[$type] ?? null;
}

/**
Expand Down

0 comments on commit b9f9cae

Please sign in to comment.