Bloom.Publish.EpubMaker.ToValidXmlId C# (CSharp) Méthode

ToValidXmlId() static private méthode

Given a filename, attempt to make a valid XML ID that is as similar as possible. - if it's OK don't change it - if it contains spaces remove them - if it starts with an invalid character add an initial 'f' - change other invalid characters to underlines We do this because ePUB technically uses XHTML and therefore follows XML rules. I doubt most readers care but validators do and we would like our ebooks to validate.
static private ToValidXmlId ( string item ) : string
item string
Résultat string
        internal static string ToValidXmlId(string item)
        {
            string output = item.Replace(" ", "");
            // This conforms to http://www.w3.org/TR/REC-xml/#NT-Name except that we don't handle valid characters above FFFF.
            string validStartRanges =
                ":A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD";
            string validChars = validStartRanges + "\\-.0-9\u00b7\u0300-\u036F\u203F-\u2040";
            output = Regex.Replace(output, "[^" + validChars + "]", "_");
            if (!new Regex("^[" + validStartRanges + "]").IsMatch(output))
                return "f" +output;
            return output;
        }