Ejemplo n.º 1
0
 public void CheckXmlLang(ValidationEventHandler eventhandler)
 {
     if (defaultValueTyped != null)
     {
         String s = defaultValueTyped.ToString();
         if (!XmlComplianceUtil.IsValidLanguageID(s.ToCharArray(), 0, s.Length))
         {
             eventhandler(this, new ValidationEventArgs(new XmlSchemaException(Res.Sch_InvalidLanguageId, s)));
         }
     }
 }
Ejemplo n.º 2
0
 private string ParseLang(string value)
 {
     if (value == null)  // Avt is not constant, or attribute wasn't defined
     {
         return(null);
     }
     if (!XmlComplianceUtil.IsValidLanguageID(value.ToCharArray(), 0, value.Length))
     {
         if (this.forwardCompatibility)
         {
             return(null);
         }
         throw XsltException.Create(Res.Xslt_InvalidAttrValue, Keywords.s_Lang, value);
     }
     return(value);
 }
        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);
        }
Ejemplo n.º 4
0
 private string ParseLang(string value)
 {
     if (value == null)  // Avt is not constant, or attribute wasn't defined
     {
         return(null);
     }
     // XmlComplianceUtil.IsValidLanguageID uses the outdated RFC 1766. It would be
     // better to remove this method completely and not call it here, but that may
     // change exception types for some stylesheets.
     if (!XmlComplianceUtil.IsValidLanguageID(value.ToCharArray(), 0, value.Length) &&
         (value.Length == 0 || CultureInfo.GetCultureInfo(value) == null)
         )
     {
         if (this.forwardCompatibility)
         {
             return(null);
         }
         throw XsltException.Create(Res.Xslt_InvalidAttrValue, "lang", value);
     }
     return(value);
 }