/**
  * Merges the existing attributes with the new ones
  *
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  * @param array|string $attributes Array of attribute 'name' => 'value' pairs
  *                                 or HTML attribute string
  *
  * @return string A string containing merged attributes
  */
 function merge_attributes_and_classes($attributes, $extra_attributes)
 {
     $attributes = prepare_attributes($attributes);
     $extra_attributes = prepare_attributes($extra_attributes);
     $class_extra = get_attribute($extra_attributes, 'class');
     $attributes = add_class($attributes, get_attribute($extra_attributes, 'class'));
     $extra_attributes = remove_attribute($extra_attributes, 'class');
     return merge_attributes($attributes, $extra_attributes);
 }
if (isset($config['general']['preg_delete'])) {
    $replacements['preg_delete'] = $config['general']['preg_delete'];
} else {
    $replacements['preg_delete'] = array();
}
// init index section info
$index_section = prepare_index_section($config, $index_section_name);
if (empty($index_section)) {
    throw new Exception('Index not found, check sphinx_xmlpipe_conf.ini');
}
$doc = new SphinxXMLFeed();
/**
 * Print schema section
 */
$doc->setFields($index_section['xmlpipe_field']);
$xml_doc_attr_list = prepare_attributes($index_section);
$doc->setAttributes($xml_doc_attr_list);
$doc->beginOutput();
/**
 * Execute pre queries and get range
 */
if (isset($index_section['sql_query_pre']) and is_array($index_section['sql_query_pre'])) {
    $args = array('{table_prefix}' => $table_prefix);
    execute_support_queries($mysqli, $index_section['sql_query_pre'], $args, 'Error in "execute pre_query" section: %s');
}
$message_field = $index_section['message_field'];
$query = str_replace('{table_prefix}', $table_prefix, $index_section['sql_query_range']);
$mysqli_result = $mysqli->query($query);
if (!$mysqli_result) {
    throw new Exception('Error in "get range" section:' . $mysqli->error);
}