示例#1
0
 public IList GetSchemas(string?ns)
 {
     return((IList)SchemaSet.Schemas(ns));
 }
示例#2
0
        /// <include file='doc\XmlSchemas.uex' path='docs/doc[@for="XmlSchemas.Compile"]/*' />
        public void Compile(ValidationEventHandler handler, bool fullCompile)
        {
            if (isCompiled)
            {
                return;
            }

            foreach (XmlSchema s in delayedSchemas.Values)
            {
                Merge(s);
            }
            delayedSchemas.Clear();

            if (fullCompile)
            {
                schemaSet                         = new XmlSchemaSet();
                schemaSet.XmlResolver             = null;
                schemaSet.ValidationEventHandler += handler;

                foreach (XmlSchema s in References.Values)
                {
                    schemaSet.Add(s);
                }
                int schemaCount = schemaSet.Count;

                foreach (XmlSchema s in List)
                {
                    if (!SchemaSet.Contains(s))
                    {
                        schemaSet.Add(s);
                        schemaCount++;
                    }
                }

                if (!SchemaSet.Contains(XmlSchema.Namespace))
                {
                    AddReference(XsdSchema);
                    schemaSet.Add(XsdSchema);
                    schemaCount++;
                }

                if (!SchemaSet.Contains(XmlReservedNs.NsXml))
                {
                    AddReference(XmlSchema);
                    schemaSet.Add(XmlSchema);
                    schemaCount++;
                }
                schemaSet.Compile();
                schemaSet.ValidationEventHandler -= handler;
                isCompiled = schemaSet.IsCompiled && schemaCount == schemaSet.Count;
            }
            else
            {
                try {
                    XmlNameTable nameTable = new System.Xml.NameTable();
                    Preprocessor prep      = new Preprocessor(nameTable, new SchemaNames(nameTable), null);
                    prep.XmlResolver      = null;
                    prep.SchemaLocations  = new Hashtable();
                    prep.ChameleonSchemas = new Hashtable();
                    foreach (XmlSchema schema in SchemaSet.Schemas())
                    {
                        prep.Execute(schema, schema.TargetNamespace, true);
                    }
                }
                catch (XmlSchemaException e) {
                    throw CreateValidationException(e, e.Message);
                }
            }
        }