ValidatePrefix() публичный статический Метод

public static ValidatePrefix ( string prefix ) : bool
prefix string
Результат bool
        private void AddScript(Compiler compiler)
        {
            NavigatorInput input = compiler.Input;

            ScriptingLanguage lang = ScriptingLanguage.JScript;
            string            implementsNamespace = null;

            if (input.MoveToFirstAttribute())
            {
                do
                {
                    if (input.LocalName == input.Atoms.Language)
                    {
                        string langName = input.Value;
                        if (
                            String.Compare(langName, "jscript", StringComparison.OrdinalIgnoreCase) == 0 ||
                            String.Compare(langName, "javascript", StringComparison.OrdinalIgnoreCase) == 0
                            )
                        {
                            lang = ScriptingLanguage.JScript;
                        }
                        else if (
                            String.Compare(langName, "c#", StringComparison.OrdinalIgnoreCase) == 0 ||
                            String.Compare(langName, "csharp", StringComparison.OrdinalIgnoreCase) == 0
                            )
                        {
                            lang = ScriptingLanguage.CSharp;
                        }
                        else
                        {
                            throw XsltException.Create(Res.Xslt_ScriptInvalidLanguage, langName);
                        }
                    }
                    else if (input.LocalName == input.Atoms.ImplementsPrefix)
                    {
                        if (!PrefixQName.ValidatePrefix(input.Value))
                        {
                            throw XsltException.Create(Res.Xslt_InvalidAttrValue, input.LocalName, input.Value);
                        }
                        implementsNamespace = compiler.ResolveXmlNamespace(input.Value);
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            if (implementsNamespace == null)
            {
                throw XsltException.Create(Res.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
            }
            if (!input.Recurse() || input.NodeType != XPathNodeType.Text)
            {
                throw XsltException.Create(Res.Xslt_ScriptEmpty);
            }
            compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber);
            input.ToParent();
        }
Пример #2
0
 public string GetNsAlias(ref string prefix)
 {
     Debug.Assert(
         Ref.Equal(_input.LocalName, _input.Atoms.StylesheetPrefix) ||
         Ref.Equal(_input.LocalName, _input.Atoms.ResultPrefix)
         );
     if (prefix == "#default")
     {
         prefix = string.Empty;
         return(this.DefaultNamespace);
     }
     else
     {
         if (!PrefixQName.ValidatePrefix(prefix))
         {
             throw XsltException.Create(SR.Xslt_InvalidAttrValue, _input.LocalName, prefix);
         }
         return(this.ResolveXPathNamespace(prefix));
     }
 }
Пример #3
0
 public string GetNsAlias(ref string prefix)
 {
     Debug.Assert(
         Keywords.Equals(this.input.LocalName, this.input.Atoms.StylesheetPrefix) ||
         Keywords.Equals(this.input.LocalName, this.input.Atoms.ResultPrefix)
         );
     if (Keywords.Compare(this.input.Atoms.HashDefault, prefix))
     {
         prefix = string.Empty;
         return(this.DefaultNamespace);
     }
     else
     {
         if (!PrefixQName.ValidatePrefix(prefix))
         {
             throw XsltException.Create(Res.Xslt_InvalidAttrValue, this.input.LocalName, prefix);
         }
         return(this.ResolveXPathNamespace(prefix));
     }
 }
Пример #4
0
        private static double NameTest(string name)
        {
            if (name == "*")
            {
                return(-0.5);
            }
            int idx = name.Length - 2;

            if (0 <= idx && name[idx] == ':' && name[idx + 1] == '*')
            {
                if (!PrefixQName.ValidatePrefix(name.Substring(0, idx)))
                {
                    throw XsltException.Create(SR.Xslt_InvalidAttrValue, "elements", name);
                }
                return(-0.25);
            }
            else
            {
                PrefixQName.ParseQualifiedName(name, out _, out _);
                return(0);
            }
        }
        double NameTest(String name)
        {
            if (name == "*")
            {
                return(-0.5);
            }
            int idx = name.Length - 2;

            if (0 <= idx && name[idx] == ':' && name[idx + 1] == '*')
            {
                if (!PrefixQName.ValidatePrefix(name.Substring(0, idx)))
                {
                    throw XsltException.Create(Res.Xslt_InvalidAttrValue, Keywords.s_Elements, name);
                }
                return(-0.25);
            }
            else
            {
                string prefix, localname;
                PrefixQName.ParseQualifiedName(name, out prefix, out localname);
                return(0);
            }
        }