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();
}