internal void CheckWhitespaceFacets(ref string s, XmlSchemaDatatype datatype) { RestrictionFacets restriction = datatype.Restriction; switch (datatype.Variety) { case XmlSchemaDatatypeVariety.Atomic: if (datatype.BuiltInWhitespaceFacet != XmlSchemaWhiteSpace.Collapse) { if (datatype.BuiltInWhitespaceFacet == XmlSchemaWhiteSpace.Replace) { s = XmlComplianceUtil.CDataNormalize(s); } else if ((restriction != null) && ((restriction.Flags & RestrictionFlags.WhiteSpace) != 0)) { if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Replace) { s = XmlComplianceUtil.CDataNormalize(s); return; } if (restriction.WhiteSpace == XmlSchemaWhiteSpace.Collapse) { s = XmlComplianceUtil.NonCDataNormalize(s); } } return; } s = XmlComplianceUtil.NonCDataNormalize(s); return; case XmlSchemaDatatypeVariety.List: s = s.Trim(); return; } }
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))); } } }
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); }
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); }
public XmlSchema Add(string targetNamespace, string schemaUri) { if ((schemaUri == null) || (schemaUri.Length == 0)) { throw new ArgumentNullException("schemaUri"); } if (targetNamespace != null) { targetNamespace = XmlComplianceUtil.CDataNormalize(targetNamespace); } XmlSchema schema = null; lock (this.InternalSyncObject) { System.Xml.XmlResolver xmlResolver = this.readerSettings.GetXmlResolver(); if (xmlResolver == null) { xmlResolver = new XmlUrlResolver(); } Uri uri = xmlResolver.ResolveUri(null, schemaUri); if (this.IsSchemaLoaded(uri, targetNamespace, out schema)) { return(schema); } XmlReader reader = XmlReader.Create(schemaUri, this.readerSettings); try { schema = this.Add(targetNamespace, this.ParseSchema(targetNamespace, reader)); while (reader.Read()) { } } finally { reader.Close(); } } return(schema); }
public XmlSchema Add(string targetNamespace, XmlReader schemaDocument) { if (schemaDocument == null) { throw new ArgumentNullException("schemaDocument"); } if (targetNamespace != null) { targetNamespace = XmlComplianceUtil.CDataNormalize(targetNamespace); } lock (this.InternalSyncObject) { XmlSchema schema = null; Uri schemaUri = new Uri(schemaDocument.BaseURI, UriKind.RelativeOrAbsolute); if (!this.IsSchemaLoaded(schemaUri, targetNamespace, out schema)) { DtdProcessing dtdProcessing = this.readerSettings.DtdProcessing; this.SetDtdProcessing(schemaDocument); schema = this.Add(targetNamespace, this.ParseSchema(targetNamespace, schemaDocument)); this.readerSettings.DtdProcessing = dtdProcessing; } return(schema); } }
internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue) { typedValue = XmlComplianceUtil.NonCDataNormalize(s); return(null); }