public ScriptClass GetScriptClass(string ns, string language, IErrorHelper errorHelper) { CompilerInfo compilerInfo; try { compilerInfo = CodeDomProvider.GetCompilerInfo(language); Debug.Assert(compilerInfo != null); } catch (ConfigurationException) { // There is no CodeDom provider defined for this language errorHelper.ReportError(/*[XT_010]*/ Res.Xslt_ScriptInvalidLanguage, language); return(null); } foreach (ScriptClass scriptClass in scriptClasses) { if (ns == scriptClass.ns) { // Use object comparison because CompilerInfo.Equals may throw if (compilerInfo != scriptClass.compilerInfo) { errorHelper.ReportError(/*[XT_011]*/ Res.Xslt_ScriptMixedLanguages, ns); return(null); } return(scriptClass); } } ScriptClass newScriptClass = new ScriptClass(ns, compilerInfo); newScriptClass.typeDecl.TypeAttributes = TypeAttributes.Public; scriptClasses.Add(newScriptClass); return(newScriptClass); }
internal static string LangToNameInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { string cultName = InvariantCultureName; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/ SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { cultName = new CultureInfo(lang).Name; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/ SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return(cultName); }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return(lcid); }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // Check if lang is valid language tag according to RFC 3066 if (!XmlComplianceUtil.IsValidLanguageID(lang.ToCharArray(), 0, lang.Length)) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/ Res.Xslt_InvalidLanguageTag, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguageTag, lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/ Res.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguage, lang); } } } } } return(lcid); }
public void ValidatePiName(string name, IErrorHelper errorHelper) { Debug.Assert(name != null); try { ValidateNames.ValidateNameThrow( /*prefix:*/ string.Empty, /*localName:*/ name, /*ns:*/ string.Empty, XPathNodeType.ProcessingInstruction, ValidateNames.Flags.AllExceptPrefixMapping ); } catch (XmlException e) { errorHelper.ReportError(/*[XT_044]*/ e.Message, null); } }
public bool ParseNameTest(string nameTest, out string prefix, out string localName, IErrorHelper errorHelper) { Debug.Assert(nameTest != null); try { ValidateNames.ParseNameTestThrow(nameTest, out prefix, out localName); return(true); } catch (XmlException e) { errorHelper.ReportError(/*[XT_043]*/ e.Message, null); prefix = PhantomNCName; localName = PhantomNCName; return(false); } }
public XmlExtensionFunction ResolveFunction(string name, string ns, int numArgs, IErrorHelper errorHelper) { Type type; if (nsToType.TryGetValue(ns, out type)) { try { return(extFuncs.Bind(name, ns, numArgs, type, XmlQueryRuntime.EarlyBoundFlags)); } catch (XslTransformException e) { errorHelper.ReportError(e.Message); } } return(null); }
public ScriptClass GetScriptClass(string ns, string language, IErrorHelper errorHelper) { CompilerInfo compilerInfo; try { compilerInfo = CodeDomProvider.GetCompilerInfo(language); Debug.Assert(compilerInfo != null); } catch (ConfigurationException) { // There is no CodeDom provider defined for this language errorHelper.ReportError(/*[XT_010]*/SR.Xslt_ScriptInvalidLanguage, language); return null; } foreach (ScriptClass scriptClass in _scriptClasses) { if (ns == scriptClass.ns) { // Use object comparison because CompilerInfo.Equals may throw if (compilerInfo != scriptClass.compilerInfo) { errorHelper.ReportError(/*[XT_011]*/SR.Xslt_ScriptMixedLanguages, ns); return null; } return scriptClass; } } ScriptClass newScriptClass = new ScriptClass(ns, compilerInfo); newScriptClass.typeDecl.TypeAttributes = TypeAttributes.Public; _scriptClasses.Add(newScriptClass); return newScriptClass; }
public XmlExtensionFunction ResolveFunction(string name, string ns, int numArgs, IErrorHelper errorHelper) { Type type; if (_nsToType.TryGetValue(ns, out type)) { try { return _extFuncs.Bind(name, ns, numArgs, type, XmlQueryRuntime.EarlyBoundFlags); } catch (XslTransformException e) { errorHelper.ReportError(e.Message); } } return null; }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/Res.Xslt_InvalidAttrValue, "lang", lang); } else { throw new XslTransformException(Res.Xslt_InvalidAttrValue, "lang", lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/Res.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguage, lang); } } } } } return lcid; }
internal static string LangToNameInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { string cultName = InvariantCultureName; if (lang != null) { // The value of the 'lang' attribute must be a non-empty nmtoken if (lang.Length == 0) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/SR.Xslt_InvalidAttrValue, nameof(lang), lang); } else { throw new XslTransformException(SR.Xslt_InvalidAttrValue, nameof(lang), lang); } } } else { // Check if lang is a supported culture name try { cultName = new CultureInfo(lang).Name; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/SR.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(SR.Xslt_InvalidLanguage, lang); } } } } } return cultName; }
internal static int LangToLcidInternal(string lang, bool forwardCompatibility, IErrorHelper errorHelper) { int lcid = InvariantCultureLcid; if (lang != null) { // Check if lang is valid language tag according to RFC 3066 if (!XmlComplianceUtil.IsValidLanguageID(lang.ToCharArray(), 0, lang.Length)) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_032]*/Res.Xslt_InvalidLanguageTag, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguageTag, lang); } } } else { // Check if lang is a supported culture name try { lcid = new CultureInfo(lang).LCID; } catch (System.ArgumentException) { if (!forwardCompatibility) { if (errorHelper != null) { errorHelper.ReportError(/*[XT_033]*/Res.Xslt_InvalidLanguage, lang); } else { throw new XslTransformException(Res.Xslt_InvalidLanguage, lang); } } } } } return lcid; }