Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 65 to 95

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 15th December 2024 10:35 Europe/London time based on the source file dated 6th March 2024 14:45 Europe/London time.