コード例 #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)
            {
                HashSet <string> validatableXmlNamespaces = new HashSet <string>();
                double           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));
        }
コード例 #2
0
        /// <summary>
        /// Adds Store schema resource entries to the given XmlNamespace to XmlSchemaResoure map
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddStoreSchemaResourceMapEntries(Dictionary <string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource[] ssdlImports = { new XmlSchemaResource(XmlConstants.EntityStoreSchemaGeneratorNamespace, "System.Data.Resources.EntityStoreSchemaGenerator.xsd") };

            XmlSchemaResource ssdlSchema = new XmlSchemaResource(XmlConstants.TargetNamespace_1, "System.Data.Resources.SSDLSchema.xsd", ssdlImports);

            schemaResourceMap.Add(ssdlSchema.NamespaceUri, ssdlSchema);

            if (schemaVersion >= XmlConstants.StoreVersionForV2)
            {
                XmlSchemaResource ssdlSchema2 = new XmlSchemaResource(XmlConstants.TargetNamespace_2, "System.Data.Resources.SSDLSchema_2.xsd", ssdlImports);
                schemaResourceMap.Add(ssdlSchema2.NamespaceUri, ssdlSchema2);
            }

            if (schemaVersion >= XmlConstants.StoreVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.StoreVersionForV3, "Did you add a new schema version");

                XmlSchemaResource ssdlSchema3 = new XmlSchemaResource(XmlConstants.TargetNamespace_3, "System.Data.Resources.SSDLSchema_3.xsd", ssdlImports);
                schemaResourceMap.Add(ssdlSchema3.NamespaceUri, ssdlSchema3);
            }

            XmlSchemaResource providerManifest = new XmlSchemaResource(XmlConstants.ProviderManifestNamespace, "System.Data.Resources.ProviderServices.ProviderManifest.xsd");

            schemaResourceMap.Add(providerManifest.NamespaceUri, providerManifest);
        }
コード例 #3
0
        /// <summary>
        /// Adds Store schema resource entries to the given XmlNamespace to XmlSchemaResoure map
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddStoreSchemaResourceMapEntries(Dictionary<string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource[] ssdlImports = {
                new XmlSchemaResource(
                    XmlConstants.EntityStoreSchemaGeneratorNamespace,
                    "System.Data.Resources.EntityStoreSchemaGenerator.xsd")
            };

            var ssdlSchema = new XmlSchemaResource(XmlConstants.TargetNamespace_1, "System.Data.Resources.SSDLSchema.xsd", ssdlImports);
            schemaResourceMap.Add(ssdlSchema.NamespaceUri, ssdlSchema);

            if (schemaVersion >= XmlConstants.StoreVersionForV2)
            {
                var ssdlSchema2 = new XmlSchemaResource(
                    XmlConstants.TargetNamespace_2, "System.Data.Resources.SSDLSchema_2.xsd", ssdlImports);
                schemaResourceMap.Add(ssdlSchema2.NamespaceUri, ssdlSchema2);
            }

            if (schemaVersion >= XmlConstants.StoreVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.StoreVersionForV3, "Did you add a new schema version");

                var ssdlSchema3 = new XmlSchemaResource(
                    XmlConstants.TargetNamespace_3, "System.Data.Resources.SSDLSchema_3.xsd", ssdlImports);
                schemaResourceMap.Add(ssdlSchema3.NamespaceUri, ssdlSchema3);
            }

            var providerManifest = new XmlSchemaResource(
                XmlConstants.ProviderManifestNamespace, "System.Data.Resources.ProviderServices.ProviderManifest.xsd");
            schemaResourceMap.Add(providerManifest.NamespaceUri, providerManifest);
        }
コード例 #4
0
 public XmlSchemaResource(string namespaceUri, string resourceName, XmlSchemaResource[] importedSchemas)
 {
     Debug.Assert(!string.IsNullOrEmpty(namespaceUri), "namespaceUri is null or empty");
     Debug.Assert(!string.IsNullOrEmpty(resourceName), "resourceName is null or empty");
     Debug.Assert(importedSchemas != null, "importedSchemas is null");
     NamespaceUri = namespaceUri;
     ResourceName = resourceName;
     ImportedSchemas = importedSchemas;
 }
コード例 #5
0
            private static void AddXmlSchemaToSet(XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, HashSet <string> schemasAlreadyAdded)
            {
                // loop through the children to do a depth first load
                foreach (var import in schemaResource.ImportedSchemas)
                {
                    AddXmlSchemaToSet(schemaSet, import, schemasAlreadyAdded);
                }

                if (!schemasAlreadyAdded.Contains(schemaResource.NamespaceUri))
                {
                    Stream    xsdStream = GetResourceStream(schemaResource.ResourceName);
                    XmlSchema schema    = XmlSchema.Read(xsdStream, null);
                    schemaSet.Add(schema);
                    schemasAlreadyAdded.Add(schemaResource.NamespaceUri);
                }
            }
コード例 #6
0
        /// <summary>
        /// Adds Mapping schema resource entries to the given XmlNamespace to XmlSchemaResoure map
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddMappingSchemaResourceMapEntries(Dictionary <string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource msl1 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV1, StorageMslConstructs.ResourceXsdNameV1);

            schemaResourceMap.Add(msl1.NamespaceUri, msl1);

            if (schemaVersion >= XmlConstants.EdmVersionForV2)
            {
                XmlSchemaResource msl2 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV2, StorageMslConstructs.ResourceXsdNameV2);
                schemaResourceMap.Add(msl2.NamespaceUri, msl2);
            }

            if (schemaVersion >= XmlConstants.EdmVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.EdmVersionForV3, "Did you add a new schema version");
                XmlSchemaResource msl3 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV3, StorageMslConstructs.ResourceXsdNameV3);
                schemaResourceMap.Add(msl3.NamespaceUri, msl3);
            }
        }
コード例 #7
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(this.SchemaVersion).Values)
                {
                    _parseableXmlNamespaces.Add(schemaResource.NamespaceUri);
                }
            }

            return(_parseableXmlNamespaces.Contains(xmlNamespaceUri));
        }
コード例 #8
0
        /// <summary>
        /// Adds Edm schema resource entries to the given XmlNamespace to XmlSchemaResoure map,
        /// when calling from SomSchemaSetHelper.ComputeSchemaSet(), all the imported xsd will be included
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddEdmSchemaResourceMapEntries(Dictionary <string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource[] csdlImports = { new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd") };

            XmlSchemaResource[] csdl2Imports =
            {
                new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
                new XmlSchemaResource(XmlConstants.AnnotationNamespace,           "System.Data.Resources.AnnotationSchema.xsd")
            };

            XmlSchemaResource[] csdl3Imports =
            {
                new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
                new XmlSchemaResource(XmlConstants.AnnotationNamespace,           "System.Data.Resources.AnnotationSchema.xsd")
            };

            XmlSchemaResource csdlSchema_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1, "System.Data.Resources.CSDLSchema_1.xsd", csdlImports);

            schemaResourceMap.Add(csdlSchema_1.NamespaceUri, csdlSchema_1);

            XmlSchemaResource csdlSchema_1_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1_1, "System.Data.Resources.CSDLSchema_1_1.xsd", csdlImports);

            schemaResourceMap.Add(csdlSchema_1_1.NamespaceUri, csdlSchema_1_1);

            if (schemaVersion >= XmlConstants.EdmVersionForV2)
            {
                XmlSchemaResource csdlSchema_2 = new XmlSchemaResource(XmlConstants.ModelNamespace_2, "System.Data.Resources.CSDLSchema_2.xsd", csdl2Imports);
                schemaResourceMap.Add(csdlSchema_2.NamespaceUri, csdlSchema_2);
            }

            if (schemaVersion >= XmlConstants.EdmVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.EdmVersionForV3, "Did you add a new schema version");

                XmlSchemaResource csdlSchema_3 = new XmlSchemaResource(XmlConstants.ModelNamespace_3, "System.Data.Resources.CSDLSchema_3.xsd", csdl3Imports);
                schemaResourceMap.Add(csdlSchema_3.NamespaceUri, csdlSchema_3);
            }
        }
コード例 #9
0
            private static XmlSchemaSet ComputeSchemaSet(SchemaDataModelOption dataModel)
            {
                List <string> namespaceNames = GetPrimarySchemaNamespaces(dataModel);

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

                XmlSchemaSet 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);
                HashSet <string> schemasAlreadyAdded = new HashSet <string>();

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

                return(schemaSet);
            }
コード例 #10
0
 private static void AddAllSchemaResourceNamespaceNames(HashSet <string> hashSet, XmlSchemaResource schemaResource)
 {
     hashSet.Add(schemaResource.NamespaceUri);
     foreach (var import in schemaResource.ImportedSchemas)
     {
         AddAllSchemaResourceNamespaceNames(hashSet, import);
     }
 }
コード例 #11
0
        /// <summary>
        /// Adds Mapping schema resource entries to the given XmlNamespace to XmlSchemaResoure map
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddMappingSchemaResourceMapEntries(Dictionary<string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource msl1 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV1, StorageMslConstructs.ResourceXsdNameV1);
            schemaResourceMap.Add(msl1.NamespaceUri, msl1);

            if (schemaVersion >= XmlConstants.EdmVersionForV2)
            {
                XmlSchemaResource msl2 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV2, StorageMslConstructs.ResourceXsdNameV2);
                schemaResourceMap.Add(msl2.NamespaceUri, msl2);
            }

            if (schemaVersion >= XmlConstants.EdmVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.EdmVersionForV3, "Did you add a new schema version");
                XmlSchemaResource msl3 = new XmlSchemaResource(StorageMslConstructs.NamespaceUriV3, StorageMslConstructs.ResourceXsdNameV3);
                schemaResourceMap.Add(msl3.NamespaceUri, msl3);
            }
        }
コード例 #12
0
        /// <summary>
        /// Adds Edm schema resource entries to the given XmlNamespace to XmlSchemaResoure map,
        /// when calling from SomSchemaSetHelper.ComputeSchemaSet(), all the imported xsd will be included
        /// </summary>
        /// <param name="schemaResourceMap">The XmlNamespace to XmlSchemaResource map to add entries to.</param>
        internal static void AddEdmSchemaResourceMapEntries(Dictionary<string, XmlSchemaResource> schemaResourceMap, double schemaVersion)
        {
            XmlSchemaResource[] csdlImports = { new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd") };
            
            XmlSchemaResource[] csdl2Imports = { 
                new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
                new XmlSchemaResource(XmlConstants.AnnotationNamespace, "System.Data.Resources.AnnotationSchema.xsd") };

            XmlSchemaResource[] csdl3Imports = { 
                new XmlSchemaResource(XmlConstants.CodeGenerationSchemaNamespace, "System.Data.Resources.CodeGenerationSchema.xsd"),
                new XmlSchemaResource(XmlConstants.AnnotationNamespace, "System.Data.Resources.AnnotationSchema.xsd") };

            XmlSchemaResource csdlSchema_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1, "System.Data.Resources.CSDLSchema_1.xsd", csdlImports);
            schemaResourceMap.Add(csdlSchema_1.NamespaceUri, csdlSchema_1);

            XmlSchemaResource csdlSchema_1_1 = new XmlSchemaResource(XmlConstants.ModelNamespace_1_1, "System.Data.Resources.CSDLSchema_1_1.xsd", csdlImports);
            schemaResourceMap.Add(csdlSchema_1_1.NamespaceUri, csdlSchema_1_1);

            if (schemaVersion >= XmlConstants.EdmVersionForV2)
            {
                XmlSchemaResource csdlSchema_2 = new XmlSchemaResource(XmlConstants.ModelNamespace_2, "System.Data.Resources.CSDLSchema_2.xsd", csdl2Imports);
                schemaResourceMap.Add(csdlSchema_2.NamespaceUri, csdlSchema_2);
            }

            if (schemaVersion >= XmlConstants.EdmVersionForV3)
            {
                Debug.Assert(XmlConstants.SchemaVersionLatest == XmlConstants.EdmVersionForV3, "Did you add a new schema version");

                XmlSchemaResource csdlSchema_3 = new XmlSchemaResource(XmlConstants.ModelNamespace_3, "System.Data.Resources.CSDLSchema_3.xsd", csdl3Imports);
                schemaResourceMap.Add(csdlSchema_3.NamespaceUri, csdlSchema_3);
            }
        }
コード例 #13
0
ファイル: Schema.cs プロジェクト: ItsVeryWindy/mono
 private static void AddAllSchemaResourceNamespaceNames(HashSet<string> hashSet, XmlSchemaResource schemaResource)
 {
     hashSet.Add(schemaResource.NamespaceUri);
     foreach(var import in schemaResource.ImportedSchemas)
     {
         AddAllSchemaResourceNamespaceNames(hashSet, import);
     }
 }
コード例 #14
0
ファイル: Schema.cs プロジェクト: ItsVeryWindy/mono
            private static void AddXmlSchemaToSet(XmlSchemaSet schemaSet, XmlSchemaResource schemaResource, HashSet<string> schemasAlreadyAdded)
            {
                // loop through the children to do a depth first load
                foreach (var import in schemaResource.ImportedSchemas)
                {
                    AddXmlSchemaToSet(schemaSet, import, schemasAlreadyAdded);
                }

                if (!schemasAlreadyAdded.Contains(schemaResource.NamespaceUri))
                {
                    Stream xsdStream = GetResourceStream(schemaResource.ResourceName);
                    XmlSchema schema = XmlSchema.Read(xsdStream, null);
                    schemaSet.Add(schema);
                    schemasAlreadyAdded.Add(schemaResource.NamespaceUri);
                }
            }