11 [XmlRoot(
"schema", Namespace =
"http://www.w3.org/2001/XMLSchema")]
12 [global::__DynamicallyInvokable]
16 public const string Namespace =
"http://www.w3.org/2001/XMLSchema";
29 private string targetNs;
31 private string version;
41 private bool isCompiled;
43 private bool isCompiledBySet;
45 private bool isPreprocessed;
47 private bool isRedefined;
49 private int errorCount;
65 private static int globalIdCounter = -1;
71 private int schemaId = -1;
75 private bool isChameleon;
91 return attributeFormDefault;
95 attributeFormDefault = value;
111 blockDefault = value;
127 finalDefault = value;
139 return elementFormDefault;
143 elementFormDefault = value;
218 return isCompiledBySet;
225 internal bool IsCompiledBySet
229 return isCompiledBySet;
233 isCompiledBySet = value;
238 internal bool IsPreprocessed
242 return isPreprocessed;
246 isPreprocessed = value;
251 internal bool IsRedefined
270 if (attributes ==
null)
285 if (attributeGroups ==
null)
289 return attributeGroups;
315 if (elements ==
null)
345 return moreAttributes;
349 moreAttributes = value;
380 return identityConstraints;
398 internal int SchemaId
411 internal bool IsChameleon
433 internal XmlDocument Document
437 if (document ==
null)
439 document =
new XmlDocument();
446 internal int ErrorCount
459 internal override string IdAttribute
471 internal XmlNameTable NameTable
475 if (nameTable ==
null)
477 nameTable =
new NameTable();
487 if (importedSchemas ==
null)
491 return importedSchemas;
499 if (importedNamespaces ==
null)
503 return importedNamespaces;
535 Parser parser =
new Parser(SchemaType.XSD, xmlNameTable,
new SchemaNames(xmlNameTable), validationEventHandler);
538 parser.Parse(reader,
null);
542 if (validationEventHandler ==
null)
549 return parser.XmlSchema;
566 Write(xmlTextWriter, namespaceManager);
583 Write(xmlTextWriter, namespaceManager);
601 if (namespaceManager !=
null)
605 if (base.Namespaces !=
null)
607 flag = (base.Namespaces.Namespaces[
"xs"] !=
null || base.Namespaces.Namespaces.ContainsValue(
"http://www.w3.org/2001/XMLSchema"));
609 if (!flag && namespaceManager.
LookupPrefix(
"http://www.w3.org/2001/XMLSchema") ==
null && namespaceManager.
LookupNamespace(
"xs") ==
null)
611 xmlSerializerNamespaces.
Add(
"xs",
"http://www.w3.org/2001/XMLSchema");
613 foreach (
string item
in namespaceManager)
615 if (item !=
"xml" && item !=
"xmlns")
617 xmlSerializerNamespaces.
Add(item, namespaceManager.LookupNamespace(item));
621 else if (base.Namespaces !=
null && base.Namespaces.Count > 0)
623 Hashtable namespaces = base.Namespaces.Namespaces;
624 if (namespaces[
"xs"] ==
null && !namespaces.
ContainsValue(
"http://www.w3.org/2001/XMLSchema"))
626 namespaces.
Add(
"xs",
"http://www.w3.org/2001/XMLSchema");
628 xmlSerializerNamespaces = base.Namespaces;
633 xmlSerializerNamespaces.
Add(
"xs",
"http://www.w3.org/2001/XMLSchema");
634 if (targetNs !=
null && targetNs.Length != 0)
636 xmlSerializerNamespaces.
Add(
"tns", targetNs);
639 xmlSerializer.
Serialize(writer,
this, xmlSerializerNamespaces);
644 [Obsolete(
"Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
647 SchemaInfo schemaInfo =
new SchemaInfo();
648 schemaInfo.SchemaType = SchemaType.XSD;
649 CompileSchema(
null,
XmlReaderSection.CreateDefaultResolver(), schemaInfo,
null, validationEventHandler,
NameTable, CompileContentModel:
false);
655 [Obsolete(
"Use System.Xml.Schema.XmlSchemaSet for schema compilation and validation. http://go.microsoft.com/fwlink/?linkid=14202")]
658 SchemaInfo schemaInfo =
new SchemaInfo();
659 schemaInfo.SchemaType = SchemaType.XSD;
660 CompileSchema(
null, resolver, schemaInfo,
null, validationEventHandler,
NameTable, CompileContentModel:
false);
667 SchemaCollectionPreprocessor schemaCollectionPreprocessor =
new SchemaCollectionPreprocessor(nameTable,
null, validationEventHandler);
668 schemaCollectionPreprocessor.XmlResolver = resolver;
669 if (!schemaCollectionPreprocessor.Execute(
this, ns, loadExternals:
true, xsc))
673 SchemaCollectionCompiler schemaCollectionCompiler =
new SchemaCollectionCompiler(nameTable, validationEventHandler);
674 isCompiled = schemaCollectionCompiler.Execute(
this, schemaInfo, CompileContentModel);
675 SetIsCompiled(isCompiled);
680 internal void CompileSchemaInSet(XmlNameTable nameTable,
ValidationEventHandler eventHandler, XmlSchemaCompilationSettings compilationSettings)
682 Compiler compiler =
new Compiler(nameTable, eventHandler,
null, compilationSettings);
683 compiler.Prepare(
this, cleanup:
true);
684 isCompiledBySet = compiler.Compile();
687 internal new XmlSchema Clone()
689 XmlSchema xmlSchema =
new XmlSchema();
690 xmlSchema.attributeFormDefault = attributeFormDefault;
691 xmlSchema.elementFormDefault = elementFormDefault;
692 xmlSchema.blockDefault = blockDefault;
693 xmlSchema.finalDefault = finalDefault;
694 xmlSchema.targetNs = targetNs;
695 xmlSchema.version = version;
696 xmlSchema.includes = includes;
697 xmlSchema.Namespaces = base.Namespaces;
698 xmlSchema.items = items;
699 xmlSchema.BaseUri = BaseUri;
700 SchemaCollectionCompiler.Cleanup(xmlSchema);
704 internal XmlSchema DeepClone()
706 XmlSchema xmlSchema =
new XmlSchema();
707 xmlSchema.attributeFormDefault = attributeFormDefault;
708 xmlSchema.elementFormDefault = elementFormDefault;
709 xmlSchema.blockDefault = blockDefault;
710 xmlSchema.finalDefault = finalDefault;
711 xmlSchema.targetNs = targetNs;
712 xmlSchema.version = version;
713 xmlSchema.isPreprocessed = isPreprocessed;
714 for (
int i = 0; i < items.
Count; i++)
716 XmlSchemaComplexType xmlSchemaComplexType;
717 XmlSchemaElement xmlSchemaElement;
718 XmlSchemaGroup xmlSchemaGroup;
719 XmlSchemaObject item = ((xmlSchemaComplexType = (items[i] as XmlSchemaComplexType)) ==
null) ? (((xmlSchemaElement = (items[i] as XmlSchemaElement)) ==
null) ? (((xmlSchemaGroup = (items[i] as XmlSchemaGroup)) ==
null) ? items[i].Clone() : xmlSchemaGroup.Clone(
this)) : xmlSchemaElement.Clone(
this)) : xmlSchemaComplexType.Clone(
this);
720 xmlSchema.Items.Add(item);
722 for (
int j = 0; j < includes.
Count; j++)
724 XmlSchemaExternal item2 = (XmlSchemaExternal)includes[j].Clone();
727 xmlSchema.Namespaces = base.Namespaces;
728 xmlSchema.BaseUri = BaseUri;
732 internal void SetIsCompiled(
bool isCompiled)
734 this.isCompiled = isCompiled;
737 internal override void SetUnhandledAttributes(XmlAttribute[] moreAttributes)
739 this.moreAttributes = moreAttributes;
742 internal override void AddAnnotation(XmlSchemaAnnotation annotation)
744 items.
Add(annotation);
747 internal void GetExternalSchemasList(
IList extList, XmlSchema schema)
754 for (
int i = 0; i < schema.Includes.Count; i++)
756 XmlSchemaExternal xmlSchemaExternal = (XmlSchemaExternal)schema.Includes[i];
757 if (xmlSchemaExternal.Schema !=
null)
759 GetExternalSchemasList(extList, xmlSchemaExternal.Schema);
Represents an XML document. You can use this class to load, validate, edit, add, and position XML in ...
Contains the XML namespaces and prefixes that the T:System.Xml.Serialization.XmlSerializer uses to ge...
void Write(XmlWriter writer, XmlNamespaceManager namespaceManager)
Writes the XML Schema to the supplied T:System.Xml.XmlWriter.
virtual void Add(object key, object value)
Adds an element with the specified key and value into the T:System.Collections.Hashtable.
void Write(Stream stream, XmlNamespaceManager namespaceManager)
Writes the XML Schema to the supplied T:System.IO.Stream using the T:System.Xml.XmlNamespaceManager s...
XmlSchemaObjectTable Groups
Gets the post-schema-compilation value of all the groups in the schema.
XmlSchemaDerivationMethod BlockDefault
Gets or sets the blockDefault attribute which sets the default value of the block attribute on elemen...
void Add(string prefix, string ns)
Adds a prefix and namespace pair to an T:System.Xml.Serialization.XmlSerializerNamespaces object.
Represents the attributeGroup element from the XML Schema as specified by the World Wide Web Consorti...
XmlSchemaObjectCollection Items
Gets the collection of schema elements in the schema and is used to add new element types at the sche...
string TargetNamespace
Gets or sets the Uniform Resource Identifier (URI) of the schema target namespace.
Represents a non-generic collection of objects that can be individually accessed by index.
XmlSchemaForm
Indicates if attributes or elements need to be qualified with a namespace prefix.
A collection of T:System.Xml.Schema.XmlSchemaObjects.
Represents the root class for the Xml schema object model hierarchy and serves as a base class for cl...
XmlSchemaObjectTable Elements
Gets the post-schema-compilation value for all the elements in the schema.
Resolves external XML resources named by a Uniform Resource Identifier (URI).
Represents an attribute. Valid and default values for the attribute are defined in a document type de...
bool IsCompiled
Indicates if the schema has been compiled.
Represents the include element from XML Schema as specified by the World Wide Web Consortium (W3C)....
void Compile(ValidationEventHandler validationEventHandler, XmlResolver resolver)
Compiles the XML Schema Object Model (SOM) into schema information for validation....
Represents a writer that provides a fast, non-cached, forward-only way to generate streams or files t...
Represents a reader that provides fast, non-cached, forward-only access to XML data....
XmlSchemaObjectCollection Includes
Gets the collection of included and imported schemas.
Represents a reader that provides fast, noncached, forward-only access to XML data....
XmlSchemaObjectTable Attributes
Gets the post-schema-compilation value for all the attributes in the schema.
static XmlSchema Read(TextReader reader, ValidationEventHandler validationEventHandler)
Reads an XML Schema from the supplied T:System.IO.TextReader.
XmlSchemaObjectTable AttributeGroups
Gets the post-schema-compilation value of all the global attribute groups in the schema.
Implements a single-threaded T:System.Xml.XmlNameTable.
Represents the group element from XML Schema as specified by the World Wide Web Consortium (W3C)....
Represents the notation element from XML Schema as specified by the World Wide Web Consortium (W3C)....
delegate void ValidationEventHandler(object sender, ValidationEventArgs e)
Represents the callback method that will handle XML schema validation events and the T:System....
int Add(XmlSchemaObject item)
Adds an T:System.Xml.Schema.XmlSchemaObject to the XmlSchemaObjectCollection.
Represents a collection of key/value pairs that are organized based on the hash code of the key....
Represents the import element from XML Schema as specified by the World Wide Web Consortium (W3C)....
void Compile(ValidationEventHandler validationEventHandler)
Compiles the XML Schema Object Model (SOM) into schema information for validation....
Represents a writer that provides a fast, non-cached, forward-only way of generating streams or files...
Resolves, adds, and removes namespaces to a collection and provides scope management for these namesp...
virtual string LookupPrefix(string uri)
Finds the prefix declared for the given namespace URI.
Represents the complexType element from XML Schema as specified by the World Wide Web Consortium (W3C...
Represents a writer that can write a sequential series of characters. This class is abstract.
static int Increment(ref int location)
Increments a specified variable and stores the result, as an atomic operation.
Serializes and deserializes objects into and from XML documents. The T:System.Xml....
Provides the collections for contained elements in the T:System.Xml.Schema.XmlSchema class (for examp...
static XmlSchema Read(Stream stream, ValidationEventHandler validationEventHandler)
Reads an XML Schema from the supplied stream.
XmlSchemaForm ElementFormDefault
Gets or sets the form for elements declared in the target namespace of the schema.
Represents the version number of an assembly, operating system, or the common language runtime....
int Add(object value)
Adds an item to the T:System.Collections.IList.
Table of atomized string objects.
const string InstanceNamespace
The XML schema instance namespace. This field is constant.
virtual bool ContainsValue(object value)
Determines whether the T:System.Collections.Hashtable contains a specific value.
const string Namespace
The XML schema namespace. This field is constant.
XmlSchemaForm AttributeFormDefault
Gets or sets the form for attributes declared in the target namespace of the schema.
void Write(TextWriter writer, XmlNamespaceManager namespaceManager)
Writes the XML Schema to the supplied T:System.IO.TextWriter.
Formatting Formatting
Indicates how the output is formatted.
XmlSchemaObjectTable Notations
Gets the post-schema-compilation value for all notations in the schema.
void Write(XmlWriter writer)
Writes the XML Schema to the supplied T:System.Xml.XmlWriter.
int Count
Gets the number of elements contained in the T:System.Collections.CollectionBase instance....
Represents the element element from XML Schema as specified by the World Wide Web Consortium (W3C)....
XmlSchemaObjectTable SchemaTypes
Gets the post-schema-compilation value of all schema types in the schema.
Represents a reader that can read a sequential series of characters.
An in-memory representation of an XML Schema, as specified in the World Wide Web Consortium (W3C) XML...
XmlSchemaDerivationMethod FinalDefault
Gets or sets the finalDefault attribute which sets the default value of the final attribute on elemen...
void Write(Stream stream)
Writes the XML Schema to the supplied data stream.
Formatting
Specifies formatting options for the T:System.Xml.XmlTextWriter.
XmlAttribute [] UnhandledAttributes
Gets and sets the qualified attributes which do not belong to the schema target namespace.
virtual string LookupNamespace(string prefix)
Gets the namespace URI for the specified prefix.
bool Contains(object value)
Determines whether the T:System.Collections.IList contains a specific value.
static XmlSchema Read(XmlReader reader, ValidationEventHandler validationEventHandler)
Reads an XML Schema from the supplied T:System.Xml.XmlReader.
void Serialize(TextWriter textWriter, object o)
Serializes the specified T:System.Object and writes the XML document to a file using the specified T:...
Represents the World Wide Web Consortium (W3C) annotation element.
Returns detailed information about the schema exception.
Provides an object representation of a uniform resource identifier (URI) and easy access to the parts...
void Write(TextWriter writer)
Writes the XML Schema to the supplied T:System.IO.TextWriter.
XmlSchemaDerivationMethod
Provides different methods for preventing derivation.
Represents the simpleType element for simple content from XML Schema as specified by the World Wide W...
Represents the redefine element from XML Schema as specified by the World Wide Web Consortium (W3C)....
Provides atomic operations for variables that are shared by multiple threads.
Returns detailed information related to the ValidationEventHandler.
Represents the attribute element from the XML Schema as specified by the World Wide Web Consortium (W...
string Id
Gets or sets the string ID.
Represents an XML reader section.
abstract XmlNameTable NameTable
When overridden in a derived class, gets the T:System.Xml.XmlNameTable associated with this implement...
Implements the T:System.Collections.IList interface using an array whose size is dynamically increase...
Contains a cache of XML Schema definition language (XSD) and XML-Data Reduced (XDR) schemas....
Provides a generic view of a sequence of bytes. This is an abstract class.To browse the ....