function _views_oai_pmh_xml_tag_clean in Views OAI-PMH 6.2
Same name and namespace in other branches
- 6 theme/views_oai_pmh.theme.inc \_views_oai_pmh_xml_tag_clean()
- 7 theme/views_oai_pmh.theme.inc \_views_oai_pmh_xml_tag_clean()
- 7.2 theme/views_oai_pmh.theme.inc \_views_oai_pmh_xml_tag_clean()
Returns a valid XML tag formed from the given input.
Parameters
$tag The string that should be made into a valid XML tag.:
Return value
The valid XML tag or an empty string if the string contained no valid XML tag characters.
File
- theme/
views_oai_pmh.theme.inc, line 242 - Theme related functions for processing our output style plugins.
Code
function _views_oai_pmh_xml_tag_clean($tag) {
// This regex matches characters that are not valid in XML tags, and the
// unicode ones that are. We don't bother with unicode, because it would so
// the preg_replace down a lot.
static $invalid_tag_chars_regex = '#[^\\:A-Za-z_\\-.0-9]+#';
// These characters are not valid at the start of an XML tag:
static $invalid_start_chars = '-.0123456789';
// Convert invalid chars to '-':
$tag = preg_replace($invalid_tag_chars_regex, '-', $tag);
// Need to trim invalid characters from the start of the string:
$tag = ltrim($tag, $invalid_start_chars);
return $tag;
}