public class XmlSchemaComplexType : XmlSchemaType
|
using System; using System.Xml; using System.Xml.Schema; class XMLSchemaExamples { public static void Main() { XmlSchema schema = new XmlSchema(); // <xs:element name="stringElementWithAnyAttribute"> XmlSchemaElement element = new XmlSchemaElement(); schema.Items.Add(element); element.Name = "stringElementWithAnyAttribute"; // <xs:complexType> XmlSchemaComplexType complexType = new XmlSchemaComplexType(); element.SchemaType = complexType; // <xs:simpleContent> XmlSchemaSimpleContent simpleContent = new XmlSchemaSimpleContent(); complexType.ContentModel = simpleContent; // <extension base= "xs:string"> XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension(); simpleContent.Content = extension; extension.BaseTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema"); // <xs:anyAttribute namespace="##targetNamespace"/> XmlSchemaAnyAttribute anyAttribute = new XmlSchemaAnyAttribute(); extension.AnyAttribute = anyAttribute; anyAttribute.Namespace = "##targetNamespace"; schema.Compile(new ValidationEventHandler(ValidationCallbackOne)); XmlNamespaceManager nsmgr = new XmlNamespaceManager(new NameTable()); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); schema.Write(Console.Out, nsmgr); } public static void ValidationCallbackOne(object sender, ValidationEventArgs args) { Console.WriteLine(args.Message); } }
The following XML file is used for the preceding code example.
<?xml version="1.0" encoding="IBM437"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="stringElementWithAnyAttribute"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:anyAttribute namespace="##targetNamespace"/> </xs:extension> </xs:simpleContent> </xs:complexType> </xs:element> </xs:schema>
ctor #1 | Default constructor. This constructor is called by derived class constructors to initialize state in this type. Used to create a complexType element. |
Annotation (inherited from System.Xml.Schema.XmlSchemaAnnotated) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaAnnotated.Annotation Gets or sets the annotation property. |
AnyAttribute | Read-write Gets or sets the value for the XmlSchemaAnyAttribute component of the complex type. |
Attributes | Read-only Gets the collection of attributes for the complex type. |
AttributeUses | Read-only Gets the collection of all the attributes from this complex type and its base types which holds the post-compilation value of the AttributeUses property. |
AttributeWildcard | Read-only Gets the anyAttribute element from this complex type and its base types which holds the post-compilation value of the AttributeWildcard property. |
BaseSchemaType (inherited from System.Xml.Schema.XmlSchemaType) |
Read-only See base class member description: System.Xml.Schema.XmlSchemaType.BaseSchemaType Gets the object of the simpleType element or complexType element. This is a post-schema-validation-infoset variable. |
Block | Read-write Gets or sets the block attribute. |
BlockResolved | Read-only Gets the value after the type has been compiled to the post-schema-validation infoset. This value indicates how the type is enforced when xsi:type is used in the instance document. |
ContentModel | Read-write Gets or sets the content model type. |
ContentType | Read-only Gets the content model of the complex type which holds the post-compilation value. |
ContentTypeParticle | Read-only Gets the particle which holds the post-compilation value of the ContentTypeParticle property. This ContentTypeParticle is determined after the content models of the most derived types and the base complex type have been resolved according to the rules defined in the World Wide Web Consortium (W3C) XML Schema definition language (XSD) specification. |
Datatype (inherited from System.Xml.Schema.XmlSchemaType) |
Read-only See base class member description: System.Xml.Schema.XmlSchemaType.Datatype Gets the data type that holds the post-compilation value. |
DerivedBy (inherited from System.Xml.Schema.XmlSchemaType) |
Read-only See base class member description: System.Xml.Schema.XmlSchemaType.DerivedBy When overridden in a derived class, this property gets information that indicates how this element has been derived from a base type. This property holds the post-compilation value. |
Final (inherited from System.Xml.Schema.XmlSchemaType) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaType.Final Gets or sets the final property to indicate that no further derivations are allowed. |
FinalResolved (inherited from System.Xml.Schema.XmlSchemaType) |
Read-only See base class member description: System.Xml.Schema.XmlSchemaType.FinalResolved Gets the post-compilation value of the Final property that holds the post-compilation value of the Final property. |
Id (inherited from System.Xml.Schema.XmlSchemaAnnotated) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaAnnotated.Id Gets or sets the string id. |
IsAbstract | Read-write Gets or sets the information that determines if the complexType element can be used in the instance document. |
IsMixed | Read-write Overridden: Gets or sets information that determines if the complex type has a mixed content model (markup within the content). |
LineNumber (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.LineNumber Gets or sets the line number in the file to which the schema element refers. |
LinePosition (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.LinePosition Gets or sets the line position in the file to which the schema element refers. |
Name (inherited from System.Xml.Schema.XmlSchemaType) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaType.Name Gets or sets the name of the type. |
Namespaces (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.Namespaces |
Particle | Read-write Gets or sets the compositor type as one of the XmlSchemaGroupRef, XmlSchemaChoice, XmlSchemaAll, or XmlSchemaSequence classes. |
QualifiedName (inherited from System.Xml.Schema.XmlSchemaType) |
Read-only See base class member description: System.Xml.Schema.XmlSchemaType.QualifiedName Gets the qualified name for the type built from the Name attribute of this type. This holds the post-compilation value. |
SourceUri (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.SourceUri Gets or sets the source location for the file that loaded the schema. |
UnhandledAttributes (inherited from System.Xml.Schema.XmlSchemaAnnotated) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaAnnotated.UnhandledAttributes Gets or sets the qualified attributes that do not belong to the schema target namespace. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetType (inherited from System.Object) |
See base class member description: System.Object.GetType Derived from System.Object, the primary base class for all objects. |
ToString (inherited from System.Object) |
See base class member description: System.Object.ToString Derived from System.Object, the primary base class for all objects. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public XmlSchemaComplexType(); |
public XmlSchemaAnnotation Annotation {get; set;}
|
public XmlSchemaAnyAttribute AnyAttribute {get; set;}
|
public XmlSchemaObjectCollection Attributes {get;}
|
public XmlSchemaObjectTable AttributeUses {get;}
|
The value of this property is read-only. This property has the value after the schema has been successfully compiled to determine the complete attribute set that is allowed in an instance document.
public XmlSchemaAnyAttribute AttributeWildcard {get;}
|
public object BaseSchemaType {get;}
|
public XmlSchemaDerivationMethod Block {get; set;}
|
This attribute can contain the following values:
Enum | Description |
---|---|
None | Use the derivation restriction defined by the BlockDefault property of the schema, if it exists. |
Extension | This element cannot be replaced by a type derived by Extension. |
Restriction | This element cannot be replaced by a type derived by Restriction. |
All | #all . This element cannot be replaced by any type regardless of derivation method. |
The Substitution, List, and Union derivation methods are not supported by this property.
public XmlSchemaDerivationMethod BlockResolved {get;}
|
This attribute can contain the following values:
Enum | Description |
---|---|
None | Use the derivation restriction defined by the BlockDefault property of the schema, if it exists. |
Extension | This element cannot be replaced by a type derived by Extension. |
Restriction | This element cannot be replaced by a type derived by Restriction. |
All | #all . This element cannot be replaced by any type regardless of derivation method. |
The Substitution, List, and Union derivation methods are not supported by this property.
public XmlSchemaContentModel ContentModel {get; set;}
|
public XmlSchemaContentType ContentType {get;}
|
If the IsMixed property is set to true on the ContentModel property that has the type XmlSchemaComplexContent, the value returned is Mixed.
If the IsMixed property is false, the value is either Empty or ElementOnly.
If the type on the ContentModel property has the type XmlSchemaSimpleContent, then this value is always TextOnly.
The ContentType property must have one of the values shown in the following table.
Enum | Description |
---|---|
TextOnly | Text-only content. |
Empty | Empty content. |
ElementOnly | Element-only content. |
Mixed | Mixed content model. |
public XmlSchemaParticle ContentTypeParticle {get;}
|
public XmlSchemaDatatype Datatype {get;}
|
public XmlSchemaDerivationMethod DerivedBy {get;}
|
Enum | Description |
---|---|
None | No derivation method specified. |
Substitution | Derived by Substitution. |
Extension | Derived by Extension. |
Restriction | Derived by Restriction. |
List | Derived by List. |
Union | Derived by Union. |
public XmlSchemaDerivationMethod Final {get; set;}
|
Enum | Description |
---|---|
Empty | Overrides the schema blockDefault setting allowing any derivations, by restriction, extension, or substitution to take place. |
None | No derivation method is specified. This is the default. Derivation rules are taken from the schema blockDefault setting. |
Substitution | Cannot be replaced by a type derived by Substitution. |
Extension | Cannot be replaced by a type derived by Extension. |
Restriction | Cannot be replaced by a type derived by Restriction. |
All | #all . Cannot be replaced by a type derived by any derivation method. |
The following table shows the values that this property can contain for complex type.
Enum | Description |
---|---|
Empty | Overrides the schema blockDefault setting allowing any derivations, by restriction, extension, or substitution to take place. |
None | No derivation method is specified. This is the default. Derivation rules are taken from the schema blockDefault setting. |
Substitution | Cannot be replaced by a type derived by Substitution. |
Extension | Cannot be replaced by a type derived by Extension. |
Restriction | Cannot be replaced by a type derived by Restriction. |
All | #all . Cannot be replaced by a type derived by any derivation method. |
public XmlSchemaDerivationMethod FinalResolved {get;}
|
public string Id {get; set;}
|
Optional.
public bool IsAbstract {get; set;}
|
public override bool IsMixed {get; set;}
|
public int LineNumber {get; set;}
|
public int LinePosition {get; set;}
|
public string Name {get; set;}
|
public XmlSerializerNamespaces Namespaces {get; set;}
|
public XmlSchemaParticle Particle {get; set;}
|
Element | Description |
---|---|
group | The complex type contains the elements defined in the referenced group. |
sequence | The complex type contains the elements defined in the specified sequence. |
choice | The complex type allows one of the elements specified in the choice element. |
all | The complex type allows all of the elements specified in the all element to appear once or not at all. |
This is mutually exclusive with the XmlSchemaComplexType.ContentModel property.
public XmlQualifiedName QualifiedName {get;}
|
public string SourceUri {get; set;}
|
public XmlAttribute[] UnhandledAttributes {get; set;}
|
~XmlSchemaComplexType(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |