public class XmlSchemaAnyAttribute : XmlSchemaAnnotated
|
using System;
using System.Xml;
using System.Xml.Schema;
class XMLSchemaExamples {
public static void Main() {
XmlSchema schema = new XmlSchema();
// <element name="stringElementWithAnyAttribute">
XmlSchemaElement element = new XmlSchemaElement();
schema.Items.Add(element);
element.Name = "stringElementWithAnyAttribute";
// <complexType>
XmlSchemaComplexType complexType = new XmlSchemaComplexType();
element.SchemaType = complexType;
// <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");
// <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 generated 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. |
| 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. |
| 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. |
| 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. |
| Namespace | Read-write Gets or sets the namespaces containing the attributes that can be used. |
| Namespaces (inherited from System.Xml.Schema.XmlSchemaObject) |
Read-write See base class member description: System.Xml.Schema.XmlSchemaObject.Namespaces |
| ProcessContents | Read-write Gets or sets information about how an application or XML processor should handle the validation of XML documents for the attributes specified by the anyAttribute element. |
| 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 XmlSchemaAnyAttribute(); |
public XmlSchemaAnnotation Annotation {get; set;}
|
public string Id {get; set;}
|
Optional.
public int LineNumber {get; set;}
|
public int LinePosition {get; set;}
|
public string Namespace {get; set;}
|
| Namespace value | Description |
|---|---|
| ##any | Elements from any namespace can be present. |
| ##other | Elements from any namespace that is not the targetNamespace of the parent element containing the anyAttribute element can be present. |
| ##local | Elements that are not qualified with a namespace can be present. |
| ##targetNamespace | Elements from the targetNamespace of the parent element containing the anyAttribute element can be present. |
| List of {URIs,##targetNamespace, ##local} | Elements from a space-delimited list of namespaces can be present. The list can contain the following: URI references of namespaces, ##targetNamespace , and ##local . |
public XmlSerializerNamespaces Namespaces {get; set;}
|
public XmlSchemaContentProcessing ProcessContents {get; set;}
|
public string SourceUri {get; set;}
|
public XmlAttribute[] UnhandledAttributes {get; set;}
|
~XmlSchemaAnyAttribute(); |
public virtual int GetHashCode(); |
public Type GetType(); |
protected object MemberwiseClone(); |
public virtual string ToString(); |