8 [Obsolete(
"Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
15 private SchemaNames schemaNames;
19 private int timeout = -1;
21 private bool isThreadSafe =
true;
29 public int Count => collection.Count;
50 return ((XmlSchemaCollectionNode)collection[(ns !=
null) ? ns :
string.
Empty])?.Schema;
80 return collection.Count;
88 return validationEventHandler;
92 validationEventHandler = value;
119 if (nametable ==
null)
123 nameTable = nametable;
140 if (uri ==
null || uri.Length == 0)
149 xmlSchema =
Add(ns, xmlTextReader, xmlResolver);
150 while (xmlTextReader.
Read())
157 xmlTextReader.
Close();
169 return Add(ns, reader, xmlResolver);
186 SchemaInfo schemaInfo =
new SchemaInfo();
187 Parser parser =
new Parser(SchemaType.None, nt, GetSchemaNames(nt), validationEventHandler);
188 parser.XmlResolver = resolver;
189 SchemaType schemaType;
192 schemaType = parser.Parse(reader, ns);
196 SendValidationEvent(e);
199 if (schemaType == SchemaType.XSD)
201 schemaInfo.SchemaType = SchemaType.XSD;
202 return Add(ns, schemaInfo, parser.XmlSchema, compile:
true, resolver);
204 SchemaInfo xdrSchema = parser.XdrSchema;
205 return Add(ns, parser.XdrSchema,
null, compile:
true, resolver);
213 return Add(schema, xmlResolver);
227 SchemaInfo schemaInfo =
new SchemaInfo();
228 schemaInfo.SchemaType = SchemaType.XSD;
245 XmlSchemaCollectionNode xmlSchemaCollectionNode = (XmlSchemaCollectionNode)enumerator.
Value;
246 Add(xmlSchemaCollectionNode.NamespaceURI, xmlSchemaCollectionNode);
270 return collection[(ns !=
null) ? ns :
string.
Empty] !=
null;
300 XmlSchemaCollectionEnumerator enumerator = GetEnumerator();
303 if (enumerator.MoveNext())
305 if (index == array.Length && array.IsFixedSize)
309 array.SetValue(enumerator.Current, index++);
314 throw new ArgumentOutOfRangeException(
"index");
333 if (!enumerator.MoveNext())
340 if (index == array.Length)
344 array[index++] = enumerator.Current;
350 internal SchemaInfo GetSchemaInfo(
string ns)
352 return ((XmlSchemaCollectionNode)collection[(ns !=
null) ? ns :
string.
Empty])?.SchemaInfo;
359 return new SchemaNames(nt);
361 if (schemaNames ==
null)
363 schemaNames =
new SchemaNames(nameTable);
368 internal XmlSchema
Add(
string ns, SchemaInfo schemaInfo, XmlSchema schema,
bool compile)
370 return Add(ns, schemaInfo, schema, compile, xmlResolver);
373 private XmlSchema
Add(
string ns, SchemaInfo schemaInfo, XmlSchema schema,
bool compile, XmlResolver resolver)
378 if (schema.ErrorCount == 0 && compile)
380 if (!schema.CompileSchema(
this, resolver, schemaInfo, ns, validationEventHandler, nameTable, CompileContentModel:
true))
384 ns = ((schema.TargetNamespace ==
null) ?
string.
Empty : schema.TargetNamespace);
386 num += schema.ErrorCount;
390 num += schemaInfo.ErrorCount;
395 XmlSchemaCollectionNode xmlSchemaCollectionNode =
new XmlSchemaCollectionNode();
396 xmlSchemaCollectionNode.NamespaceURI = ns;
397 xmlSchemaCollectionNode.SchemaInfo = schemaInfo;
398 xmlSchemaCollectionNode.Schema = schema;
399 Add(ns, xmlSchemaCollectionNode);
405 private void Add(
string ns, XmlSchemaCollectionNode node)
413 if (collection[ns] !=
null)
415 collection.Remove(ns);
417 collection.Add(ns, node);
428 private void SendValidationEvent(XmlSchemaException e)
430 if (validationEventHandler !=
null)
432 validationEventHandler(
this,
new ValidationEventArgs(e));
XmlResolver XmlResolver
Sets the T:System.Xml.XmlResolver used for resolving DTD references.
object SyncRoot
Gets an object that can be used to synchronize access to the T:System.Collections....
The exception that is thrown when a null reference (Nothing in Visual Basic) is passed to a method th...
int Count
Gets the number of namespaces defined in this collection.
void ReleaseWriterLock()
Decrements the lock count on the writer lock.
bool MoveNext()
Advances the enumerator to the next element of the collection.
string TargetNamespace
Gets or sets the Uniform Resource Identifier (URI) of the schema target namespace.
XmlNameTable NameTable
Gets the default XmlNameTable used by the XmlSchemaCollection when loading new schemas.
XmlSchema Add(string ns, XmlReader reader)
Adds the schema contained in the T:System.Xml.XmlReader to the schema collection.
The exception that is thrown when the value of an argument is outside the allowable range of values a...
ValidationEventHandler ValidationEventHandler
Sets an event handler for receiving information about the XDR and XML schema validation errors.
Resolves external XML resources named by a Uniform Resource Identifier (URI).
XmlSchema Add(XmlSchema schema)
Adds the T:System.Xml.Schema.XmlSchema to the collection.
XmlSchemaCollectionEnumerator GetEnumerator()
Provides support for the "for each" style iteration over the collection of schemas.
static Delegate Remove(Delegate source, Delegate value)
Removes the last occurrence of the invocation list of a delegate from the invocation list of another ...
static Delegate Combine(Delegate a, Delegate b)
Concatenates the invocation lists of two delegates.
Defines a lock that supports single writers and multiple readers.
Represents a reader that provides fast, non-cached, forward-only access to XML data....
Supports a simple iteration over a collection. This class cannot be inherited.
Represents a reader that provides fast, noncached, forward-only access to XML data....
XmlSchema Add(XmlSchema schema, XmlResolver resolver)
Adds the T:System.Xml.Schema.XmlSchema to the collection. The specified T:System.Xml....
Exposes an enumerator, which supports a simple iteration over a non-generic collection....
Implements a single-threaded T:System.Xml.XmlNameTable.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
XmlSchemaCollection(XmlNameTable nametable)
Initializes a new instance of the XmlSchemaCollection class with the specified T:System....
XmlSchemaCollection()
Initializes a new instance of the XmlSchemaCollection class.
XmlSchema Add(string ns, XmlReader reader, XmlResolver resolver)
Adds the schema contained in the T:System.Xml.XmlReader to the schema collection. The specified T:Sys...
void AcquireWriterLock(int millisecondsTimeout)
Acquires the writer lock, using an T:System.Int32 value for the time-out.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
bool IsSynchronized
Gets a value indicating whether access to the T:System.Collections.ICollection is synchronized (threa...
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
bool Contains(XmlSchema schema)
Gets a value indicating whether the targetNamespace of the specified T:System.Xml....
static Hashtable Synchronized(Hashtable table)
Returns a synchronized (thread-safe) wrapper for the T:System.Collections.Hashtable.
override void Close()
Changes the P:System.Xml.XmlReader.ReadState to Closed.
Table of atomized string objects.
bool Contains(string ns)
Gets a value indicating whether a schema with the specified namespace is in the collection.
IEnumerator GetEnumerator()
Returns an enumerator that iterates through a collection.
abstract string Add(char[] array, int offset, int length)
When overridden in a derived class, atomizes the specified string and adds it to the XmlNameTable.
An in-memory representation of an XML Schema, as specified in the World Wide Web Consortium (W3C) XML...
object Value
Gets the value of the current dictionary entry.
override bool Read()
Reads the next node from the stream.
Enumerates the elements of a nongeneric dictionary.
XmlSchema Add(string ns, string uri)
Adds the schema located by the given URL into the schema collection.
void CopyTo(XmlSchema[] array, int index)
Copies all the XmlSchema objects from this collection into the given array starting at the given inde...
int Count
Gets the number of elements contained in the T:System.Collections.ICollection.
Returns detailed information about the schema exception.
Defines size, enumerators, and synchronization methods for all nongeneric collections.
void CopyTo(Array array, int index)
Copies the elements of the T:System.Collections.ICollection to an T:System.Array, starting at a parti...
Supports a simple iteration over a non-generic collection.
void Add(XmlSchemaCollection schema)
Adds all the namespaces defined in the given collection (including their associated schemas) to this ...
Represents an XML reader section.
abstract XmlNameTable NameTable
When overridden in a derived class, gets the T:System.Xml.XmlNameTable associated with this implement...
Contains a cache of XML Schema definition language (XSD) and XML-Data Reduced (XDR) schemas....