mscorlib(4.0.0.0) API with additions
XmlSchemaElement.cs
3 
4 namespace System.Xml.Schema
5 {
8  {
9  private bool isAbstract;
10 
11  private bool hasAbstractAttribute;
12 
13  private bool isNillable;
14 
15  private bool hasNillableAttribute;
16 
17  private bool isLocalTypeDerivationChecked;
18 
20 
22 
23  private XmlSchemaForm form;
24 
25  private string defaultValue;
26 
27  private string fixedValue;
28 
29  private string name;
30 
31  private XmlQualifiedName refName = XmlQualifiedName.Empty;
32 
33  private XmlQualifiedName substitutionGroup = XmlQualifiedName.Empty;
34 
35  private XmlQualifiedName typeName = XmlQualifiedName.Empty;
36 
37  private XmlSchemaType type;
38 
39  private XmlQualifiedName qualifiedName = XmlQualifiedName.Empty;
40 
41  private XmlSchemaType elementType;
42 
43  private XmlSchemaDerivationMethod blockResolved;
44 
45  private XmlSchemaDerivationMethod finalResolved;
46 
47  private XmlSchemaObjectCollection constraints;
48 
49  private SchemaElementDecl elementDecl;
50 
53  [XmlAttribute("abstract")]
54  [DefaultValue(false)]
55  public bool IsAbstract
56  {
57  get
58  {
59  return isAbstract;
60  }
61  set
62  {
63  isAbstract = value;
64  hasAbstractAttribute = true;
65  }
66  }
67 
70  [XmlAttribute("block")]
73  {
74  get
75  {
76  return block;
77  }
78  set
79  {
80  block = value;
81  }
82  }
83 
86  [XmlAttribute("default")]
87  [DefaultValue(null)]
88  public string DefaultValue
89  {
90  get
91  {
92  return defaultValue;
93  }
94  set
95  {
96  defaultValue = value;
97  }
98  }
99 
102  [XmlAttribute("final")]
105  {
106  get
107  {
108  return final;
109  }
110  set
111  {
112  final = value;
113  }
114  }
115 
118  [XmlAttribute("fixed")]
119  [DefaultValue(null)]
120  public string FixedValue
121  {
122  get
123  {
124  return fixedValue;
125  }
126  set
127  {
128  fixedValue = value;
129  }
130  }
131 
134  [XmlAttribute("form")]
136  public XmlSchemaForm Form
137  {
138  get
139  {
140  return form;
141  }
142  set
143  {
144  form = value;
145  }
146  }
147 
150  [XmlAttribute("name")]
151  [DefaultValue("")]
152  public string Name
153  {
154  get
155  {
156  return name;
157  }
158  set
159  {
160  name = value;
161  }
162  }
163 
166  [XmlAttribute("nillable")]
167  [DefaultValue(false)]
168  public bool IsNillable
169  {
170  get
171  {
172  return isNillable;
173  }
174  set
175  {
176  isNillable = value;
177  hasNillableAttribute = true;
178  }
179  }
180 
181  [XmlIgnore]
182  internal bool HasNillableAttribute
183  {
184  get
185  {
186  return hasNillableAttribute;
187  }
188  }
189 
190  [XmlIgnore]
191  internal bool HasAbstractAttribute
192  {
193  get
194  {
195  return hasAbstractAttribute;
196  }
197  }
198 
201  [XmlAttribute("ref")]
202  public XmlQualifiedName RefName
203  {
204  get
205  {
206  return refName;
207  }
208  set
209  {
210  refName = ((value == null) ? XmlQualifiedName.Empty : value);
211  }
212  }
213 
216  [XmlAttribute("substitutionGroup")]
218  {
219  get
220  {
221  return substitutionGroup;
222  }
223  set
224  {
225  substitutionGroup = ((value == null) ? XmlQualifiedName.Empty : value);
226  }
227  }
228 
231  [XmlAttribute("type")]
233  {
234  get
235  {
236  return typeName;
237  }
238  set
239  {
240  typeName = ((value == null) ? XmlQualifiedName.Empty : value);
241  }
242  }
243 
246  [XmlElement("complexType", typeof(XmlSchemaComplexType))]
247  [XmlElement("simpleType", typeof(XmlSchemaSimpleType))]
248  public XmlSchemaType SchemaType
249  {
250  get
251  {
252  return type;
253  }
254  set
255  {
256  type = value;
257  }
258  }
259 
262  [XmlElement("key", typeof(XmlSchemaKey))]
263  [XmlElement("keyref", typeof(XmlSchemaKeyref))]
264  [XmlElement("unique", typeof(XmlSchemaUnique))]
266  {
267  get
268  {
269  if (constraints == null)
270  {
271  constraints = new XmlSchemaObjectCollection();
272  }
273  return constraints;
274  }
275  }
276 
279  [XmlIgnore]
281  {
282  get
283  {
284  return qualifiedName;
285  }
286  }
287 
290  [XmlIgnore]
291  [Obsolete("This property has been deprecated. Please use ElementSchemaType property that returns a strongly typed element type. http://go.microsoft.com/fwlink/?linkid=14202")]
292  public object ElementType
293  {
294  get
295  {
296  if (elementType == null)
297  {
298  return null;
299  }
300  if (elementType.QualifiedName.Namespace == "http://www.w3.org/2001/XMLSchema")
301  {
302  return elementType.Datatype;
303  }
304  return elementType;
305  }
306  }
307 
310  [XmlIgnore]
312  {
313  get
314  {
315  return elementType;
316  }
317  }
318 
321  [XmlIgnore]
323  {
324  get
325  {
326  return blockResolved;
327  }
328  }
329 
332  [XmlIgnore]
334  {
335  get
336  {
337  return finalResolved;
338  }
339  }
340 
341  [XmlIgnore]
342  internal bool HasDefault
343  {
344  get
345  {
346  if (defaultValue != null)
347  {
348  return defaultValue.Length > 0;
349  }
350  return false;
351  }
352  }
353 
354  internal bool HasConstraints
355  {
356  get
357  {
358  if (constraints != null)
359  {
360  return constraints.Count > 0;
361  }
362  return false;
363  }
364  }
365 
366  internal bool IsLocalTypeDerivationChecked
367  {
368  get
369  {
370  return isLocalTypeDerivationChecked;
371  }
372  set
373  {
374  isLocalTypeDerivationChecked = value;
375  }
376  }
377 
378  internal SchemaElementDecl ElementDecl
379  {
380  get
381  {
382  return elementDecl;
383  }
384  set
385  {
386  elementDecl = value;
387  }
388  }
389 
390  [XmlIgnore]
391  internal override string NameAttribute
392  {
393  get
394  {
395  return Name;
396  }
397  set
398  {
399  Name = value;
400  }
401  }
402 
403  [XmlIgnore]
404  internal override string NameString
405  {
406  get
407  {
408  return qualifiedName.ToString();
409  }
410  }
411 
412  internal XmlReader Validate(XmlReader reader, XmlResolver resolver, XmlSchemaSet schemaSet, ValidationEventHandler valEventHandler)
413  {
414  if (schemaSet != null)
415  {
416  XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
417  xmlReaderSettings.ValidationType = ValidationType.Schema;
418  xmlReaderSettings.Schemas = schemaSet;
419  xmlReaderSettings.ValidationEventHandler += valEventHandler;
420  return new XsdValidatingReader(reader, resolver, xmlReaderSettings, this);
421  }
422  return null;
423  }
424 
425  internal void SetQualifiedName(XmlQualifiedName value)
426  {
427  qualifiedName = value;
428  }
429 
430  internal void SetElementType(XmlSchemaType value)
431  {
432  elementType = value;
433  }
434 
435  internal void SetBlockResolved(XmlSchemaDerivationMethod value)
436  {
437  blockResolved = value;
438  }
439 
440  internal void SetFinalResolved(XmlSchemaDerivationMethod value)
441  {
442  finalResolved = value;
443  }
444 
445  internal override XmlSchemaObject Clone()
446  {
447  return Clone(null);
448  }
449 
450  internal XmlSchemaObject Clone(XmlSchema parentSchema)
451  {
452  XmlSchemaElement xmlSchemaElement = (XmlSchemaElement)MemberwiseClone();
453  xmlSchemaElement.refName = refName.Clone();
454  xmlSchemaElement.substitutionGroup = substitutionGroup.Clone();
455  xmlSchemaElement.typeName = typeName.Clone();
456  xmlSchemaElement.qualifiedName = qualifiedName.Clone();
457  XmlSchemaComplexType xmlSchemaComplexType = type as XmlSchemaComplexType;
458  if (xmlSchemaComplexType != null && xmlSchemaComplexType.QualifiedName.IsEmpty)
459  {
460  xmlSchemaElement.type = (XmlSchemaType)xmlSchemaComplexType.Clone(parentSchema);
461  }
462  xmlSchemaElement.constraints = null;
463  return xmlSchemaElement;
464  }
465  }
466 }
The base class for all simple types and complex types.
Definition: XmlSchemaType.cs:7
bool IsAbstract
Gets or sets information to indicate if the element can be used in an instance document.
XmlSchemaType ElementSchemaType
Gets an T:System.Xml.Schema.XmlSchemaType object representing the type of the element based on the P:...
XmlSchemaForm
Indicates if attributes or elements need to be qualified with a namespace prefix.
Definition: XmlSchemaForm.cs:7
A collection of T:System.Xml.Schema.XmlSchemaObjects.
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
This class represents the key element from XMLSchema as specified by the World Wide Web Consortium (W...
Definition: XmlSchemaKey.cs:4
object ElementType
Gets a common language runtime (CLR) object based on the T:System.Xml.Schema.XmlSchemaElement or T:Sy...
ValidationType
Specifies the type of validation to perform.
XmlQualifiedName? SchemaTypeName
Gets or sets the name of a built-in data type defined in this schema or another schema indicated by t...
string Namespace
Gets a string representation of the namespace of the T:System.Xml.XmlQualifiedName.
string DefaultValue
Gets or sets the default value of the element if its content is a simple type or content of the eleme...
This class represents the keyref element from XMLSchema as specified by the World Wide Web Consortium...
bool IsNillable
Gets or sets information that indicates if xsi:nil can occur in the instance data....
delegate void ValidationEventHandler(object sender, ValidationEventArgs e)
Represents the callback method that will handle XML schema validation events and the T:System....
Represents the complexType element from XML Schema as specified by the World Wide Web Consortium (W3C...
string Name
Gets or sets the name of the element.
Represents an element.
Definition: XmlElement.cs:7
Represents an XML qualified name.
XmlSchemaDerivationMethod FinalResolved
Gets the post-compilation value of the Final property.
XmlSchemaDerivationMethod BlockResolved
Gets the post-compilation value of the Block property.
XmlQualifiedName QualifiedName
Gets the actual qualified name for the given element.
string FixedValue
Gets or sets the fixed value.
XmlQualifiedName? RefName
Gets or sets the reference name of an element declared in this schema (or another schema indicated by...
int Count
Gets the number of elements contained in the T:System.Collections.CollectionBase instance....
static readonly XmlQualifiedName Empty
Provides an empty T:System.Xml.XmlQualifiedName.
Represents the element element from XML Schema as specified by the World Wide Web Consortium (W3C)....
override string ToString()
Returns the string value of the 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...
XmlSchemaObjectCollection Constraints
Gets the collection of constraints on the element.
XmlSchemaDerivationMethod Block
Gets or sets a Block derivation.
Abstract class for that is the base class for all particle types (e.g. T:System.Xml....
Represents the unique element from XML Schema as specified by the World Wide Web Consortium (W3C)....
XmlSchemaForm Form
Gets or sets the form for the element.
XmlSchemaDerivationMethod
Provides different methods for preventing derivation.
Represents the simpleType element for simple content from XML Schema as specified by the World Wide W...
XmlQualifiedName? SubstitutionGroup
Gets or sets the name of an element that is being substituted by this element.
XmlSchemaDerivationMethod Final
Gets or sets the Final property to indicate that no further derivations are allowed.