public static function escapeXmlAttrUnquoted($s) { $s = (string) $s; return preg_match('#^[a-z0-9:-]+$#i', $s) ? $s : '"' . self::escapeXml($s) . '"'; }