You are here

protected static function views_oai_pmh_plugin_style::prepare_tag in Views OAI-PMH 7.3

Prepare a tag.

Given a tag originating from a mapping string, cleans it from mapping codes (so it becomes proper for addition to the XML document), and returns an xpath pattern useful to check if the element already exists.

2 calls to views_oai_pmh_plugin_style::prepare_tag()
views_oai_pmh_plugin_style::append_record_metadata in plugins/views_oai_pmh_plugin_style.inc
Builds the core of a record's XML.
views_oai_pmh_plugin_style::eat_attributes in plugins/views_oai_pmh_plugin_style.inc
Check whether any of the available attributes applies to elements.

File

plugins/views_oai_pmh_plugin_style.inc, line 666
Contains the base OAI-PMH style plugin.

Class

views_oai_pmh_plugin_style
Views OAI-PMH_plugin style.

Code

protected static function prepare_tag(&$tag, $delta = 0) {
  $matches = array();
  if (preg_match('/^(.+)\\[([0-9]+)\\]$/', $tag, $matches)) {

    // Mapping element has a '[0-9]' suffix. Use that directly as the xpath.
    $xpath_pattern = $tag;

    // Replace with string without suffix.
    $tag = $matches[1];
  }
  elseif (preg_match('/^(.+)\\[\\]$/', $tag, $matches)) {

    // Mapping element has a '[]' suffix. Fill brackets with current delta.
    // Replace with string without suffix.
    $tag = $matches[1];
    $xpath_pattern = $tag . '[' . ($delta + 1) . ']';
  }
  else {
    $xpath_pattern = $tag;
  }
  return $xpath_pattern;
}