Example #1
0
        public bool IsValidateableXmlNamespace(string xmlNamespaceUri, bool isAttribute)
        {
            if (string.IsNullOrEmpty(xmlNamespaceUri) && isAttribute)
            {
                // we own the empty namespace for attributes
                return(true);
            }

            if (_validatableXmlNamespaces == null)
            {
                var validatableXmlNamespaces = new HashSet <string>();
                var schemaVersion            = SchemaVersion == XmlConstants.UndefinedVersion ? XmlConstants.SchemaVersionLatest : SchemaVersion;
                foreach (var schemaResource in XmlSchemaResource.GetMetadataSchemaResourceMap(schemaVersion).Values)
                {
                    AddAllSchemaResourceNamespaceNames(validatableXmlNamespaces, schemaResource);
                }

                if (SchemaVersion == XmlConstants.UndefinedVersion)
                {
                    // we are getting called before the version is set
                    return(validatableXmlNamespaces.Contains(xmlNamespaceUri));
                }
                _validatableXmlNamespaces = validatableXmlNamespaces;
            }

            return(_validatableXmlNamespaces.Contains(xmlNamespaceUri));
        }
Example #2
0
 public bool IsParseableXmlNamespace(string xmlNamespaceUri, bool isAttribute)
 {
     if (string.IsNullOrEmpty(xmlNamespaceUri) && isAttribute)
     {
         return(true);
     }
     if (this._parseableXmlNamespaces == null)
     {
         this._parseableXmlNamespaces = new HashSet <string>();
         foreach (XmlSchemaResource xmlSchemaResource in XmlSchemaResource.GetMetadataSchemaResourceMap(this.SchemaVersion).Values)
         {
             this._parseableXmlNamespaces.Add(xmlSchemaResource.NamespaceUri);
         }
     }
     return(this._parseableXmlNamespaces.Contains(xmlNamespaceUri));
 }
Example #3
0
            private static XmlSchemaSet ComputeSchemaSet(SchemaDataModelOption dataModel)
            {
                List <string> schemaNamespaces = System.Data.Entity.Core.SchemaObjectModel.Schema.SomSchemaSetHelper.GetPrimarySchemaNamespaces(dataModel);
                XmlSchemaSet  schemaSet        = new XmlSchemaSet();

                schemaSet.XmlResolver = (XmlResolver)null;
                Dictionary <string, XmlSchemaResource> schemaResourceMap = XmlSchemaResource.GetMetadataSchemaResourceMap(3.0);
                HashSet <string> schemasAlreadyAdded = new HashSet <string>();

                foreach (string index in schemaNamespaces)
                {
                    XmlSchemaResource schemaResource = schemaResourceMap[index];
                    System.Data.Entity.Core.SchemaObjectModel.Schema.SomSchemaSetHelper.AddXmlSchemaToSet(schemaSet, schemaResource, schemasAlreadyAdded);
                }
                schemaSet.Compile();
                return(schemaSet);
            }
Example #4
0
        public bool IsParseableXmlNamespace(string xmlNamespaceUri, bool isAttribute)
        {
            if (string.IsNullOrEmpty(xmlNamespaceUri) && isAttribute)
            {
                // we own the empty namespace for attributes
                return(true);
            }

            if (_parseableXmlNamespaces == null)
            {
                _parseableXmlNamespaces = new HashSet <string>();
                foreach (var schemaResource in XmlSchemaResource.GetMetadataSchemaResourceMap(SchemaVersion).Values)
                {
                    _parseableXmlNamespaces.Add(schemaResource.NamespaceUri);
                }
            }

            return(_parseableXmlNamespaces.Contains(xmlNamespaceUri));
        }
Example #5
0
 public bool IsValidateableXmlNamespace(string xmlNamespaceUri, bool isAttribute)
 {
     if (string.IsNullOrEmpty(xmlNamespaceUri) && isAttribute)
     {
         return(true);
     }
     if (this._validatableXmlNamespaces == null)
     {
         HashSet <string> hashSet = new HashSet <string>();
         foreach (XmlSchemaResource schemaResource in XmlSchemaResource.GetMetadataSchemaResourceMap(this.SchemaVersion == 0.0 ? 3.0 : this.SchemaVersion).Values)
         {
             System.Data.Entity.Core.SchemaObjectModel.Schema.AddAllSchemaResourceNamespaceNames(hashSet, schemaResource);
         }
         if (this.SchemaVersion == 0.0)
         {
             return(hashSet.Contains(xmlNamespaceUri));
         }
         this._validatableXmlNamespaces = hashSet;
     }
     return(this._validatableXmlNamespaces.Contains(xmlNamespaceUri));
 }
Example #6
0
            private static XmlSchemaSet ComputeSchemaSet(SchemaDataModelOption dataModel)
            {
                var namespaceNames = GetPrimarySchemaNamespaces(dataModel);

                Debug.Assert(namespaceNames.Count > 0, "Unknown Datamodel");

                var schemaSet = new XmlSchemaSet();

                // remove the default XmlResolver which will look on
                // disk for the referenced schemas that we already provided
                schemaSet.XmlResolver = null;
                var schemaResourceMap   = XmlSchemaResource.GetMetadataSchemaResourceMap(XmlConstants.SchemaVersionLatest);
                var schemasAlreadyAdded = new HashSet <string>();

                foreach (var namespaceName in namespaceNames)
                {
                    Debug.Assert(schemaResourceMap.ContainsKey(namespaceName), "the namespace name is not one we have a schema set for");
                    var schemaResource = schemaResourceMap[namespaceName];
                    AddXmlSchemaToSet(schemaSet, schemaResource, schemasAlreadyAdded);
                }
                schemaSet.Compile();

                return(schemaSet);
            }