mscorlib(4.0.0.0) API with additions
XmlSchemaAttribute.cs
3 
4 namespace System.Xml.Schema
5 {
8  {
9  private string defaultValue;
10 
11  private string fixedValue;
12 
13  private string name;
14 
15  private XmlSchemaForm form;
16 
17  private XmlSchemaUse use;
18 
19  private XmlQualifiedName refName = XmlQualifiedName.Empty;
20 
21  private XmlQualifiedName typeName = XmlQualifiedName.Empty;
22 
23  private XmlQualifiedName qualifiedName = XmlQualifiedName.Empty;
24 
25  private XmlSchemaSimpleType type;
26 
27  private XmlSchemaSimpleType attributeType;
28 
29  private SchemaAttDef attDef;
30 
33  [XmlAttribute("default")]
34  [DefaultValue(null)]
35  public string DefaultValue
36  {
37  get
38  {
39  return defaultValue;
40  }
41  set
42  {
43  defaultValue = value;
44  }
45  }
46 
49  [XmlAttribute("fixed")]
50  [DefaultValue(null)]
51  public string FixedValue
52  {
53  get
54  {
55  return fixedValue;
56  }
57  set
58  {
59  fixedValue = value;
60  }
61  }
62 
65  [XmlAttribute("form")]
67  public XmlSchemaForm Form
68  {
69  get
70  {
71  return form;
72  }
73  set
74  {
75  form = value;
76  }
77  }
78 
81  [XmlAttribute("name")]
82  public string Name
83  {
84  get
85  {
86  return name;
87  }
88  set
89  {
90  name = value;
91  }
92  }
93 
96  [XmlAttribute("ref")]
98  {
99  get
100  {
101  return refName;
102  }
103  set
104  {
105  refName = ((value == null) ? XmlQualifiedName.Empty : value);
106  }
107  }
108 
111  [XmlAttribute("type")]
113  {
114  get
115  {
116  return typeName;
117  }
118  set
119  {
120  typeName = ((value == null) ? XmlQualifiedName.Empty : value);
121  }
122  }
123 
126  [XmlElement("simpleType")]
127  public XmlSchemaSimpleType SchemaType
128  {
129  get
130  {
131  return type;
132  }
133  set
134  {
135  type = value;
136  }
137  }
138 
141  [XmlAttribute("use")]
142  [DefaultValue(XmlSchemaUse.None)]
143  public XmlSchemaUse Use
144  {
145  get
146  {
147  return use;
148  }
149  set
150  {
151  use = value;
152  }
153  }
154 
157  [XmlIgnore]
159  {
160  get
161  {
162  return qualifiedName;
163  }
164  }
165 
168  [XmlIgnore]
169  [Obsolete("This property has been deprecated. Please use AttributeSchemaType property that returns a strongly typed attribute type. http://go.microsoft.com/fwlink/?linkid=14202")]
170  public object AttributeType
171  {
172  get
173  {
174  if (attributeType == null)
175  {
176  return null;
177  }
178  if (attributeType.QualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema")
179  {
180  return attributeType.Datatype;
181  }
182  return attributeType;
183  }
184  }
185 
188  [XmlIgnore]
190  {
191  get
192  {
193  return attributeType;
194  }
195  }
196 
197  [XmlIgnore]
198  internal XmlSchemaDatatype Datatype
199  {
200  get
201  {
202  if (attributeType != null)
203  {
204  return attributeType.Datatype;
205  }
206  return null;
207  }
208  }
209 
210  internal SchemaAttDef AttDef
211  {
212  get
213  {
214  return attDef;
215  }
216  set
217  {
218  attDef = value;
219  }
220  }
221 
222  internal bool HasDefault => defaultValue != null;
223 
224  [XmlIgnore]
225  internal override string NameAttribute
226  {
227  get
228  {
229  return Name;
230  }
231  set
232  {
233  Name = value;
234  }
235  }
236 
237  internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler)
238  {
239  if (schemaSet != null)
240  {
241  XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
242  xmlReaderSettings.ValidationType = ValidationType.Schema;
243  xmlReaderSettings.Schemas = schemaSet;
244  xmlReaderSettings.ValidationEventHandler += valEventHandler;
245  return new XsdValidatingReader(reader, resolver, xmlReaderSettings, this);
246  }
247  return null;
248  }
249 
250  internal void SetQualifiedName(XmlQualifiedName value)
251  {
252  qualifiedName = value;
253  }
254 
255  internal void SetAttributeType(XmlSchemaSimpleType value)
256  {
257  attributeType = value;
258  }
259 
260  internal override XmlSchemaObject Clone()
261  {
262  XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute)MemberwiseClone();
263  xmlSchemaAttribute.refName = refName.Clone();
264  xmlSchemaAttribute.typeName = typeName.Clone();
265  xmlSchemaAttribute.qualifiedName = qualifiedName.Clone();
266  return xmlSchemaAttribute;
267  }
268  }
269 }
XmlSchemaUse Use
Gets or sets information about how the attribute is used.
The T:System.Xml.Schema.XmlSchemaDatatype class is an abstract class for mapping XML Schema definitio...
XmlSchemaForm
Indicates if attributes or elements need to be qualified with a namespace prefix.
Definition: XmlSchemaForm.cs:7
XmlSchemaDatatype Datatype
Gets the post-compilation value for the data type of the complex type.
Definition: __Canon.cs:3
Represents an attribute. Valid and default values for the attribute are defined in a document type de...
Definition: XmlAttribute.cs:7
The base class for any element that can contain annotation elements.
ValidationType
Specifies the type of validation to perform.
string DefaultValue
Gets or sets the default value for the attribute.
XmlSchemaUse
Indicator of how the attribute is used.
Definition: XmlSchemaUse.cs:6
string Namespace
Gets a string representation of the namespace of the T:System.Xml.XmlQualifiedName.
XmlQualifiedName? SchemaTypeName
Gets or sets the name of the simple type defined in this schema (or another schema indicated by the s...
delegate void ValidationEventHandler(object sender, ValidationEventArgs e)
Represents the callback method that will handle XML schema validation events and the T:System....
Represents an element.
Definition: XmlElement.cs:7
object AttributeType
Gets the common language runtime (CLR) object based on the P:System.Xml.Schema.XmlSchemaAttribute....
XmlQualifiedName QualifiedName
Gets the qualified name for the attribute.
Represents an XML qualified name.
string Name
Gets or sets the name of the attribute.
XmlQualifiedName? RefName
Gets or sets the name of an attribute declared in this schema (or another schema indicated by the spe...
XmlSchemaSimpleType AttributeSchemaType
Gets an T:System.Xml.Schema.XmlSchemaSimpleType object representing the type of the attribute based o...
XmlSchemaForm Form
Gets or sets the form for the attribute.
static readonly XmlQualifiedName Empty
Provides an empty T:System.Xml.XmlQualifiedName.
XmlQualifiedName QualifiedName
Gets the qualified name for the type built from the Name attribute of this type. This is a post-schem...
Represents the simpleType element for simple content from XML Schema as specified by the World Wide W...
Represents the attribute element from the XML Schema as specified by the World Wide Web Consortium (W...
string FixedValue
Gets or sets the fixed value for the attribute.