Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

getFitsMetadataFieldValue()

Description

Get metadata value for a FITS field

to look for that value in XML by converting it to an XPath query string.
Example:
video.mimeType would point to

<metadata>
<video>
[...]
<mimeType toolname="MediaInfo" toolversion="0.7.75" status="SINGLE_RESULT">video/quicktime</mimeType>
[...]
</video>
</metadata>

Parameters

ColumnTypeDefaultDescription
$xml SimpleXMLElement FITS metadata XML
$fits_field string A ResourceSpace specific FITS field mapping which allows ResourceSpace to know exactly where

Return

string

Location

include/metadata_functions.php lines 61 to 91

Definition

 
function getFitsMetadataFieldValue(SimpleXMLElement $xml $fits_field)
    {
    
// IMPORTANT: Not using "fits" namespace (or any for that matter) will yield no results
    // TODO: since there can be multiple namespaces (especially if run with -xc options) we might need to implement the
    // ability to use namespaces directly from RS FITS Field.
    
$xml->registerXPathNamespace('fits''http://hul.harvard.edu/ois/xml/ns/fits/fits_output');

    
// Convert fits field mapping from rs format to namespaced XPath format
    // Example rs field mapping for an xml element value
    //   rs field is one.two.three which converts to an xpath filter of //fits:one/fits:two/fits:three
    // Example rs field mapping for an xml attribute value (attributes are not qualified by the namespace)
    //   rs attribute is one.two.three/@four which converts to an xpath filter of //fits:one/fits:two/fits:three/@four
    
$fits_path explode('.'$fits_field);
    
// Reassemble with the namespace
    
$fits_filter  "//fits:".implode('/fits:'$fits_path);

    
$result $xml->xpath($fits_filter);

    if(!isset(
$result) || false === $result || === count($result))
        {
        return 
'';
        }

    
// First result entry carries the element or attribute value
    
if( isset($result[0]) && !is_array($result[0]) )
        {
        return 
$result[0];
        }

    return 
'';
    }

This article was last updated 25th November 2020 07:05 Europe/London time based on the source file dated 11th September 2020 17:00 Europe/London time.