Esempio n. 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));
        }
Esempio n. 2
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));
        }
Esempio n. 3
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);
            }