System.Xml.Schema.XmlSchemaCollection.Add C# (CSharp) Method

Add() private method

private Add ( string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver ) : XmlSchema
ns string
schemaInfo SchemaInfo
schema XmlSchema
compile bool
resolver System.Xml.XmlResolver
return XmlSchema
        private XmlSchema Add(string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile, XmlResolver resolver)
        {
            int errorCount = 0;
            if (schema != null)
            {
                if (schema.ErrorCount == 0 && compile)
                {
                    if (!schema.CompileSchema(this, resolver, schemaInfo, ns, _validationEventHandler, _nameTable, true))
                    {
                        errorCount = 1;
                    }
                    ns = schema.TargetNamespace == null ? string.Empty : schema.TargetNamespace;
                }
                errorCount += schema.ErrorCount;
            }
            else
            {
                errorCount += schemaInfo.ErrorCount;
                //ns = ns == null? string.Empty : NameTable.Add(ns);
                ns = NameTable.Add(ns); //Added without checking for ns == null, since XDR cannot have null namespace
            }
            if (errorCount == 0)
            {
                XmlSchemaCollectionNode node = new XmlSchemaCollectionNode();
                node.NamespaceURI = ns;
                node.SchemaInfo = schemaInfo;
                node.Schema = schema;
                Add(ns, node);
                return schema;
            }
            return null;
        }

Same methods

XmlSchemaCollection::Add ( String ns, XmlReader reader ) : XmlSchema
XmlSchemaCollection::Add ( String ns, XmlReader reader, XmlResolver resolver ) : XmlSchema
XmlSchemaCollection::Add ( XmlSchema schema ) : XmlSchema
XmlSchemaCollection::Add ( XmlSchema schema, XmlResolver resolver ) : XmlSchema
XmlSchemaCollection::Add ( string ns, SchemaInfo schemaInfo, XmlSchema schema, bool compile ) : XmlSchema
XmlSchemaCollection::Add ( string ns, string uri ) : XmlSchema
XmlSchemaCollection::Add ( XmlSchemaCollection schema ) : void
XmlSchemaCollection::Add ( string ns, XmlSchemaCollectionNode node ) : void

Usage Example

		public void TestAdd ()
		{
			XmlSchemaCollection col = new XmlSchemaCollection ();
			XmlSchema schema = new XmlSchema ();
			XmlSchemaElement elem = new XmlSchemaElement ();
			elem.Name = "foo";
			schema.Items.Add (elem);
			schema.TargetNamespace = "urn:foo";
			col.Add (schema);
			col.Add (schema);	// No problem !?

			XmlSchema schema2 = new XmlSchema ();
			schema2.Items.Add (elem);
			schema2.TargetNamespace = "urn:foo";
			col.Add (schema2);	// No problem !!

			schema.Compile (null);
			col.Add (schema);
			col.Add (schema);	// Still no problem !!!

			schema2.Compile (null);
			col.Add (schema2);

			schema = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema.Compile (null);
			col.Add (schema);

			schema2 = GetSchema ("Test/XmlFiles/xsd/3.xsd");
			schema2.Compile (null);
			col.Add (schema2);
		}
All Usage Examples Of System.Xml.Schema.XmlSchemaCollection::Add