Пример #1
0
        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;
            }
        }
Пример #2
0
        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);
        }
Пример #3
0
 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);
     }
 }