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; } #if !FEATURE_PAL // visualbasic else if ( String.Compare(langName, "vb", StringComparison.OrdinalIgnoreCase) == 0 || String.Compare(langName, "visualbasic", StringComparison.OrdinalIgnoreCase) == 0 ) { lang = ScriptingLanguage.VisualBasic; } #endif // !FEATURE_PAL else { throw XsltException.Create(SR.Xslt_ScriptInvalidLanguage, langName); } } else if (input.LocalName == input.Atoms.ImplementsPrefix) { if (!PrefixQName.ValidatePrefix(input.Value)) { throw XsltException.Create(SR.Xslt_InvalidAttrValue, input.LocalName, input.Value); } implementsNamespace = compiler.ResolveXmlNamespace(input.Value); } }while (input.MoveToNextAttribute()); input.ToParent(); } if (implementsNamespace == null) { throw XsltException.Create(SR.Xslt_MissingAttribute, input.Atoms.ImplementsPrefix); } if (!input.Recurse() || input.NodeType != XPathNodeType.Text) { throw XsltException.Create(SR.Xslt_ScriptEmpty); } compiler.AddScript(input.Value, lang, implementsNamespace, input.BaseURI, input.LineNumber); input.ToParent(); }
protected void CompileDecimalFormat(Compiler compiler) { NumberFormatInfo info = new NumberFormatInfo(); DecimalFormat format = new DecimalFormat(info, '#', '0', ';'); XmlQualifiedName Name = null; NavigatorInput input = compiler.Input; if (input.MoveToFirstAttribute()) { do { if (input.Prefix.Length != 0) { continue; } string name = input.LocalName; string value = input.Value; if (Ref.Equal(name, input.Atoms.Name)) { Name = compiler.CreateXPathQName(value); } else if (Ref.Equal(name, input.Atoms.DecimalSeparator)) { info.NumberDecimalSeparator = value; } else if (Ref.Equal(name, input.Atoms.GroupingSeparator)) { info.NumberGroupSeparator = value; } else if (Ref.Equal(name, input.Atoms.Infinity)) { info.PositiveInfinitySymbol = value; } else if (Ref.Equal(name, input.Atoms.MinusSign)) { info.NegativeSign = value; } else if (Ref.Equal(name, input.Atoms.NaN)) { info.NaNSymbol = value; } else if (Ref.Equal(name, input.Atoms.Percent)) { info.PercentSymbol = value; } else if (Ref.Equal(name, input.Atoms.PerMille)) { info.PerMilleSymbol = value; } else if (Ref.Equal(name, input.Atoms.Digit)) { if (CheckAttribute(value.Length == 1, compiler)) { format.digit = value[0]; } } else if (Ref.Equal(name, input.Atoms.ZeroDigit)) { if (CheckAttribute(value.Length == 1, compiler)) { format.zeroDigit = value[0]; } } else if (Ref.Equal(name, input.Atoms.PatternSeparator)) { if (CheckAttribute(value.Length == 1, compiler)) { format.patternSeparator = value[0]; } } }while (input.MoveToNextAttribute()); input.ToParent(); } info.NegativeInfinitySymbol = string.Concat(info.NegativeSign, info.PositiveInfinitySymbol); if (Name == null) { Name = new XmlQualifiedName(); } compiler.AddDecimalFormat(Name, format); CheckEmpty(compiler); }
internal void CompileStylesheetAttributes(Compiler compiler) { NavigatorInput input = compiler.Input; string element = input.LocalName; string badAttribute = null; string version = null; if (input.MoveToFirstAttribute()) { do { string nspace = input.NamespaceURI; string name = input.LocalName; if (nspace.Length != 0) { continue; } if (Ref.Equal(name, input.Atoms.Version)) { version = input.Value; if (1 <= XmlConvert.ToXPathDouble(version)) { compiler.ForwardCompatibility = (version != "1.0"); } else { // XmlConvert.ToXPathDouble(version) an be NaN! if (!compiler.ForwardCompatibility) { throw XsltException.Create(SR.Xslt_InvalidAttrValue, "version", version); } } } else if (Ref.Equal(name, input.Atoms.ExtensionElementPrefixes)) { compiler.InsertExtensionNamespace(input.Value); } else if (Ref.Equal(name, input.Atoms.ExcludeResultPrefixes)) { compiler.InsertExcludedNamespace(input.Value); } else if (Ref.Equal(name, input.Atoms.Id)) { // Do nothing here. } else { // We can have version atribute later. For now remember this attribute and continue badAttribute = name; } }while (input.MoveToNextAttribute()); input.ToParent(); } if (version == null) { throw XsltException.Create(SR.Xslt_MissingAttribute, "version"); } if (badAttribute != null && !compiler.ForwardCompatibility) { throw XsltException.Create(SR.Xslt_InvalidAttribute, badAttribute, element); } }