RecordXmlFormatter
in package
OAI-PMH XML Record Formatter
Tags
Table of Contents
- $globalReplace : array<string|int, mixed>
- Replacement strings for global search-and-replace.
- $globalSearch : array<string|int, mixed>
- Search strings for global search-and-replace.
- $injectDate : string|bool
- Tag to use for injecting datestamp (false for none)
- $injectHeaderElements : array<string|int, mixed>
- List of header elements to copy into body
- $injectId : string|bool
- Tag to use for injecting IDs into XML (false for none)
- $injectSetName : string|bool
- Tag to use for injecting set names (false for none)
- $injectSetSpec : string|bool
- Tag to use for injecting setSpecs (false for none)
- $setNames : array<string|int, mixed>
- Associative array of setSpec => setName
- __construct() : mixed
- Constructor
- format() : string
- Save a record to disk.
- needsSetNames() : bool
- Do we need access to set information?
- setSetNames() : void
- Inject set name information.
- createTag() : string
- Format a line of XML.
- extractHigherLevelAttributes() : array<string|int, mixed>
- Extract attributes from a higher-level tag that need to be inserted into the metadata record contained within the tag.
- fixNamespaces() : string
- Fix namespaces in the top tag of the XML document to compensate for bugs in the SimpleXML library.
- getHeaderAdditions() : string
- Format header elements as XML tags for inclusion in final record.
- getHeaderSetAdditions() : string
- Format setSpec header element as XML tags for inclusion in final record.
- getIdAdditions() : string
- Format the ID as an XML tag for inclusion in final record.
- performGlobalReplace() : string
- Perform global search and replace.
Properties
$globalReplace
Replacement strings for global search-and-replace.
protected
array<string|int, mixed>
$globalReplace
= []
$globalSearch
Search strings for global search-and-replace.
protected
array<string|int, mixed>
$globalSearch
= []
$injectDate
Tag to use for injecting datestamp (false for none)
protected
string|bool
$injectDate
= false
$injectHeaderElements
List of header elements to copy into body
protected
array<string|int, mixed>
$injectHeaderElements
= []
$injectId
Tag to use for injecting IDs into XML (false for none)
protected
string|bool
$injectId
= false
$injectSetName
Tag to use for injecting set names (false for none)
protected
string|bool
$injectSetName
= false
$injectSetSpec
Tag to use for injecting setSpecs (false for none)
protected
string|bool
$injectSetSpec
= false
$setNames
Associative array of setSpec => setName
protected
array<string|int, mixed>
$setNames
= []
Methods
__construct()
Constructor
public
__construct([array<string|int, mixed> $settings = [] ]) : mixed
Parameters
- $settings : array<string|int, mixed> = []
-
Configuration settings
Return values
mixed —format()
Save a record to disk.
public
format(string $id, object $recordObj) : string
Parameters
- $id : string
-
ID of record to save.
- $recordObj : object
-
Record to save (in SimpleXML format).
Return values
string —needsSetNames()
Do we need access to set information?
public
needsSetNames() : bool
Return values
bool —setSetNames()
Inject set name information.
public
setSetNames(array<string|int, mixed> $names) : void
Parameters
- $names : array<string|int, mixed>
-
Associative array of setSpec => setName
Return values
void —createTag()
Format a line of XML.
protected
createTag(string $tag, string $value) : string
Parameters
- $tag : string
-
Tag name
- $value : string
-
Content of tag
Return values
string —extractHigherLevelAttributes()
Extract attributes from a higher-level tag that need to be inserted into the metadata record contained within the tag.
protected
extractHigherLevelAttributes(string $raw, string $tagName, string $record) : array<string|int, mixed>
Parameters
- $raw : string
-
The full outer XML
- $tagName : string
-
The name of the outermost tag in $raw
- $record : string
-
The metadata record with the outer
tag stripped off.
Return values
array<string|int, mixed> —fixNamespaces()
Fix namespaces in the top tag of the XML document to compensate for bugs in the SimpleXML library.
protected
fixNamespaces(string $xml, array<string|int, mixed> $ns[, string $attr = '' ]) : string
Parameters
- $xml : string
-
XML document to clean up
- $ns : array<string|int, mixed>
-
Namespaces to check
- $attr : string = ''
-
Attributes extracted from the
tag
Return values
string —getHeaderAdditions()
Format header elements as XML tags for inclusion in final record.
protected
getHeaderAdditions(object $header) : string
Parameters
- $header : object
-
Header element (in SimpleXML format).
Return values
string —getHeaderSetAdditions()
Format setSpec header element as XML tags for inclusion in final record.
protected
getHeaderSetAdditions(object $setSpec) : string
Parameters
- $setSpec : object
-
Header setSpec element (in SimpleXML format).
Return values
string —getIdAdditions()
Format the ID as an XML tag for inclusion in final record.
protected
getIdAdditions(string $id) : string
Parameters
- $id : string
-
Record ID
Return values
string —performGlobalReplace()
Perform global search and replace.
protected
performGlobalReplace(string $xml) : string
Parameters
- $xml : string
-
XML to update.