Exemplo n.º 1
0
        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.ToLower(CultureInfo.InvariantCulture);   // Case insensetive !
                        if (langName == "jscript" || langName == "javascript")
                        {
                            lang = ScriptingLanguage.JScript;
                        }
                        else if (langName == "vb" || langName == "visualbasic")
                        {
                            lang = ScriptingLanguage.VisualBasic;
                        }
                        else if (langName == "c#" || langName == "csharp")
                        {
                            lang = ScriptingLanguage.CSharp;
                        }
                        else
                        {
                            throw new XsltException(Res.Xslt_ScriptInvalidLang, langName);
                        }
                    }
                    else if (input.LocalName == input.Atoms.ImplementsPrefix)
                    {
                        if (!PrefixQName.ValidatePrefix(input.Value))
                        {
                            throw XsltException.InvalidAttrValue(input.LocalName, input.Value);
                        }
                        implementsNamespace = compiler.ResolveXmlNamespace(input.Value);
                    }
                }while (input.MoveToNextAttribute());
                input.ToParent();
            }
            if (implementsNamespace == null)
            {
                throw new XsltException(Res.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix);
            }
            if (!input.Recurse() || input.NodeType != XPathNodeType.Text)
            {
                throw new XsltException(Res.Xslt_ScriptEmpty);
            }
            compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber);
            input.ToParent();
        }
Exemplo n.º 2
0
 void NameTest(String name, Compiler compiler)
 {
     if (name == "*")
     {
         return;
     }
     if (name.EndsWith(":*"))
     {
         if (!PrefixQName.ValidatePrefix(name.Substring(0, name.Length - 3)))
         {
             throw XsltException.InvalidAttrValue(compiler.Input.LocalName, name);
         }
     }
     else
     {
         string prefix, localname;
         PrefixQName.ParseQualifiedName(name, out prefix, out localname);
     }
 }
Exemplo n.º 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) || prefix.Length == 0)
         {
             throw XsltException.InvalidAttrValue(this.input.LocalName, prefix);
         }
         return(this.ResolveXPathNamespace(prefix));
     }
 }