TemplateMetadata
in package
implements
MetadataInterface
Creates <metadata> element by filling in an XML template with values read from the repository resource's metadata.
Required metadata format definitition properties:
-
templatePath
- path to the template
Optional metadata format definition properties:
For the description of the XML attributes which can be used in the template please take a look on https://github.com/acdh-oeaw/arche-oaipmh/blob/master/doc/TemplateMetadata.md
Tags
Table of Contents
Interfaces
- MetadataInterface
- Interface for different metadata providers.
Constants
- IF_LOGICAL_REGEX = '`^ *(OR|AND|NOT) *`'
- IF_PART_REGEX = '`^ *(any|every|none)[(](' . self::PREDICATE_REGEX . ')(?: +' . self::IF_VALUE_REGEX . ')?[)]`u'
- IF_VALUE_REGEX = '(==|!=|starts|ends|contains|>|<|>=|<=|regex) +(?:"([^"]*)"|\'([^\']*)\'|([0-9]+[.]?[0-9]*)|(' . self::PREDICATE_REGEX . '))'
- PREDICATE_REGEX = '[-_a-zA-Z0-9]+:[^ )]*'
Properties
- $dataset : Dataset
- $format : MetadataFormat
- Metadata format descriptor
- $headerData : HeaderData
- $loadedInverse : array<string|int, SplObjectStorage>
- $nodesStack : array<string|int, TermInterface>
- $res : RepoResourceDb
- Repository resource object
- $seqNo : int
- $template : string
- Path to the XML template file
- $valueMapper : ValueMapper
- $xml : DOMDocument
- $xmlLocation : array<string|int, string>
Methods
- __construct() : mixed
- Creates a metadata object for a given repository resource.
- extendSearchDataQuery() : QueryPart
- Allows to extend a search query with additional clauses specific to the given metadata source.
- extendSearchFilterQuery() : QueryPart
- Allows to extend a search query with additional clauses specific to the given metadata source.
- getXml() : DOMElement
- Creates resource's XML metadata
- evaluateIf() : bool
- expand() : NamedNodeInterface
- fetchValues() : array<string|int, mixed>
- loadDocument() : void
- loadMetadata() : void
- processElement() : void
- processValue() : void
- removePreservingChildren() : void
- removeUnneededNodes() : void
Constants
IF_LOGICAL_REGEX
public
mixed
IF_LOGICAL_REGEX
= '`^ *(OR|AND|NOT) *`'
IF_PART_REGEX
public
mixed
IF_PART_REGEX
= '`^ *(any|every|none)[(](' . self::PREDICATE_REGEX . ')(?: +' . self::IF_VALUE_REGEX . ')?[)]`u'
IF_VALUE_REGEX
public
mixed
IF_VALUE_REGEX
= '(==|!=|starts|ends|contains|>|<|>=|<=|regex) +(?:"([^"]*)"|\'([^\']*)\'|([0-9]+[.]?[0-9]*)|(' . self::PREDICATE_REGEX . '))'
PREDICATE_REGEX
public
mixed
PREDICATE_REGEX
= '[-_a-zA-Z0-9]+:[^ )]*'
Properties
$dataset
private
static Dataset
$dataset
$format
Metadata format descriptor
private
MetadataFormat
$format
$headerData
private
HeaderData
$headerData
$loadedInverse
private
static array<string|int, SplObjectStorage>
$loadedInverse
= []
$nodesStack
private
array<string|int, TermInterface>
$nodesStack
$res
Repository resource object
private
RepoResourceDb
$res
$seqNo
private
int
$seqNo
= 1
$template
Path to the XML template file
private
string
$template
= ''
$valueMapper
private
static ValueMapper
$valueMapper
$xml
private
DOMDocument
$xml
$xmlLocation
private
array<string|int, string>
$xmlLocation
Methods
__construct()
Creates a metadata object for a given repository resource.
public
__construct(RepoResourceDb $resource, HeaderData $searchResultRow, MetadataFormat $format) : mixed
Parameters
- $resource : RepoResourceDb
-
a repository resource object
- $searchResultRow : HeaderData
-
search query result row
- $format : MetadataFormat
-
metadata format descriptor describing this resource
extendSearchDataQuery()
Allows to extend a search query with additional clauses specific to the given metadata source.
public
static extendSearchDataQuery(MetadataFormat $format) : QueryPart
Remark! PHP doesn't consider static methods as an interface part therefore existance of this method in classes implementing this interface is not enforced.
Parameters
- $format : MetadataFormat
-
metadata format descriptor
Return values
QueryPartextendSearchFilterQuery()
Allows to extend a search query with additional clauses specific to the given metadata source.
public
static extendSearchFilterQuery(MetadataFormat $format) : QueryPart
Remark! PHP doesn't consider static methods as an interface part therefore existance of this method in classes implementing this interface is not enforced.
Parameters
- $format : MetadataFormat
-
metadata format descriptor
Return values
QueryPartgetXml()
Creates resource's XML metadata
public
getXml() : DOMElement
If the template's root element has an val
attribute a fake
root element is introduced to the template to assure it will be a valid
XML after the substitution (XML documents have to have a single root
element).
Return values
DOMElementevaluateIf()
private
evaluateIf(string $if) : bool
Parameters
- $if : string
Return values
boolexpand()
private
expand(string $prefixed) : NamedNodeInterface
Parameters
- $prefixed : string
Return values
NamedNodeInterfacefetchValues()
private
fetchValues(Value $val) : array<string|int, mixed>
Parameters
- $val : Value
Return values
array<string|int, mixed>loadDocument()
private
loadDocument() : void
loadMetadata()
private
loadMetadata(array<string|int, mixed> $resources, TermInterface|null $predicate, bool $inverse, bool $recursive) : void
Parameters
- $resources : array<string|int, mixed>
- $predicate : TermInterface|null
- $inverse : bool
- $recursive : bool
processElement()
private
processElement(DOMDocument|DOMElement $el) : void
Parameters
- $el : DOMDocument|DOMElement
processValue()
private
processValue(DOMDocument|DOMElement $el) : void
Parameters
- $el : DOMDocument|DOMElement
removePreservingChildren()
private
removePreservingChildren(DOMElement $el) : void
Parameters
- $el : DOMElement
removeUnneededNodes()
private
removeUnneededNodes(DOMDocument|DOMElement $el) : void
Parameters
- $el : DOMDocument|DOMElement