2 // System.Xml.Schema.XmlSchemaComplexType.cs
\r
5 // Dwivedi, Ajay kumar Adwiv@Yahoo.com
\r
6 // Enomoto, Atsushi ginga@kit.hi-ho.ne.jp
\r
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 using System.Collections;
\r
32 using System.ComponentModel;
\r
33 using System.Xml.Serialization;
\r
35 namespace System.Xml.Schema
\r
38 /// Summary description for XmlSchemaComplexType.
\r
40 public class XmlSchemaComplexType : XmlSchemaType
\r
42 private XmlSchemaAnyAttribute anyAttribute;
\r
43 private XmlSchemaObjectCollection attributes;
\r
44 private XmlSchemaObjectTable attributeUses;
\r
45 private XmlSchemaAnyAttribute attributeWildcard;
\r
46 private XmlSchemaDerivationMethod block;
\r
47 private XmlSchemaDerivationMethod blockResolved;
\r
48 private XmlSchemaContentModel contentModel;
\r
49 private XmlSchemaParticle validatableParticle;
\r
50 private XmlSchemaParticle contentTypeParticle;
\r
51 private bool isAbstract;
\r
52 private bool isMixed;
\r
53 private XmlSchemaParticle particle;
\r
54 private XmlSchemaContentType resolvedContentType;
\r
56 internal bool ValidatedIsAbstract;
\r
57 internal bool ParentIsSchema = false;
\r
59 const string xmlname = "complexType";
\r
61 private static XmlSchemaComplexType anyType;
\r
63 internal static XmlSchemaComplexType AnyType {
\r
65 if (anyType == null) {
\r
66 anyType = new XmlSchemaComplexType ();
\r
67 anyType.Name = ""; // In MS.NET, it is not "anyType"
\r
68 anyType.QNameInternal = XmlQualifiedName.Empty; // Not xs:anyType as well.
\r
69 #if BUGGY_MS_COMPLIANT
\r
70 anyType.validatableParticle = XmlSchemaParticle.Empty; // This code makes validator handles these schemas incorrectly: particlesIb001, mgM013, mgH014, ctE004, ctD004
\r
72 anyType.validatableParticle = XmlSchemaAny.AnyTypeContent;
\r
74 anyType.contentTypeParticle = anyType.validatableParticle;
\r
75 anyType.DatatypeInternal = XmlSchemaSimpleType.AnySimpleType;
\r
76 anyType.isMixed = true;
\r
77 anyType.resolvedContentType = XmlSchemaContentType.Mixed;
\r
83 internal static readonly XmlQualifiedName AnyTypeName = new XmlQualifiedName ("anyType", XmlSchema.Namespace);
\r
85 public XmlSchemaComplexType ()
\r
87 attributes = new XmlSchemaObjectCollection();
\r
88 block = XmlSchemaDerivationMethod.None;
\r
89 attributeUses = new XmlSchemaObjectTable();
\r
90 validatableParticle = XmlSchemaParticle.Empty;
\r
91 contentTypeParticle = validatableParticle;
\r
96 [DefaultValue(false)]
\r
97 [System.Xml.Serialization.XmlAttribute("abstract")]
\r
98 public bool IsAbstract
\r
100 get{ return isAbstract; }
\r
101 set{ isAbstract = value; }
\r
103 [DefaultValue(XmlSchemaDerivationMethod.None)]
\r
104 [System.Xml.Serialization.XmlAttribute("block")]
\r
105 public XmlSchemaDerivationMethod Block
\r
107 get{ return block; }
\r
108 set{ block = value; }
\r
110 [DefaultValue(false)]
\r
111 [System.Xml.Serialization.XmlAttribute("mixed")]
\r
112 public override bool IsMixed
\r
114 get{ return isMixed; }
\r
115 set{ isMixed = value; }
\r
122 [XmlElement("simpleContent",typeof(XmlSchemaSimpleContent))]
\r
123 [XmlElement("complexContent",typeof(XmlSchemaComplexContent))]
\r
124 public XmlSchemaContentModel ContentModel
\r
126 get{ return contentModel; }
\r
127 set{ contentModel = value; }
\r
130 //LAMESPEC: The default value for particle in Schema is of Type EmptyParticle (internal?)
\r
131 [XmlElement("group",typeof(XmlSchemaGroupRef))]
\r
132 [XmlElement("all",typeof(XmlSchemaAll))]
\r
133 [XmlElement("choice",typeof(XmlSchemaChoice))]
\r
134 [XmlElement("sequence",typeof(XmlSchemaSequence))]
\r
135 public XmlSchemaParticle Particle
\r
137 get{ return particle; }
\r
138 set{ particle = value; }
\r
141 [XmlElement("attribute",typeof(XmlSchemaAttribute))]
\r
142 [XmlElement("attributeGroup",typeof(XmlSchemaAttributeGroupRef))]
\r
143 public XmlSchemaObjectCollection Attributes
\r
145 get{ return attributes; }
\r
148 [XmlElement("anyAttribute")]
\r
149 public XmlSchemaAnyAttribute AnyAttribute
\r
151 get{ return anyAttribute; }
\r
152 set{ anyAttribute = value; }
\r
158 public XmlSchemaContentType ContentType
\r
160 get{ return resolvedContentType; }
\r
163 public XmlSchemaParticle ContentTypeParticle
\r
165 get{ return contentTypeParticle; }
\r
168 public XmlSchemaDerivationMethod BlockResolved
\r
170 get{ return blockResolved; }
\r
173 public XmlSchemaObjectTable AttributeUses
\r
175 get{ return attributeUses; }
\r
178 public XmlSchemaAnyAttribute AttributeWildcard
\r
180 get{ return attributeWildcard; }
\r
185 internal XmlSchemaParticle ValidatableParticle
\r
187 get{ return contentTypeParticle; }
\r
191 /// 1. If ContentModel is present, neither particle nor Attributes nor AnyAttribute can be present.
\r
192 /// 2. If particle is present,
\r
193 /// a. For a topLevelComplexType
\r
194 /// 1. name must be present and type NCName
\r
195 /// 2. if block is #all, blockdefault is #all, else List of (extension | restriction)
\r
196 /// 3. if final is #all, finaldefault is #all, else List of (extension | restriction)
\r
197 /// b. For a local Complex type
\r
198 /// 1. abstract must be false
\r
199 /// 2. Name must be absent
\r
200 /// 3. final must be absent
\r
201 /// 4. block must be absent
\r
204 internal override int Compile (ValidationEventHandler h, XmlSchema schema)
\r
206 // If this is already compiled this time, simply skip.
\r
207 if (this.IsComplied (schema.CompilationId))
\r
211 if (ContentModel != null)
\r
212 ContentModel.Parent = this;
\r
213 if (Particle != null)
\r
214 Particle.Parent = this;
\r
215 if (AnyAttribute != null)
\r
216 AnyAttribute.Parent = this;
\r
217 foreach (XmlSchemaObject obj in Attributes)
\r
221 ValidatedIsAbstract = isAbstract;
\r
223 if (isRedefinedComponent) {
\r
224 if (Annotation != null)
\r
225 Annotation.isRedefinedComponent = true;
\r
226 if (AnyAttribute != null)
\r
227 AnyAttribute.isRedefinedComponent = true;
\r
228 foreach (XmlSchemaObject obj in Attributes)
\r
229 obj.isRedefinedComponent = true;
\r
230 if (ContentModel != null)
\r
231 ContentModel.isRedefinedComponent = true;
\r
232 if (Particle != null)
\r
233 Particle.isRedefinedComponent = true;
\r
236 // block/final resolution
\r
237 if(ParentIsSchema || isRedefineChild)
\r
239 if(this.Name == null || this.Name == string.Empty)
\r
240 error(h,"name must be present in a top level complex type");
\r
241 else if(!XmlSchemaUtil.CheckNCName(Name))
\r
242 error(h,"name must be a NCName");
\r
244 this.QNameInternal = new XmlQualifiedName(Name, schema.TargetNamespace);
\r
246 if(Block != XmlSchemaDerivationMethod.None)
\r
248 if(Block == XmlSchemaDerivationMethod.All)
\r
250 blockResolved = XmlSchemaDerivationMethod.All;
\r
254 if ((Block & XmlSchemaUtil.ComplexTypeBlockAllowed) != Block)
\r
255 error (h, "Invalid block specification.");
\r
256 blockResolved = Block & XmlSchemaUtil.ComplexTypeBlockAllowed;
\r
261 switch (schema.BlockDefault) {
\r
262 case XmlSchemaDerivationMethod.All:
\r
263 blockResolved = XmlSchemaDerivationMethod.All;
\r
265 case XmlSchemaDerivationMethod.None:
\r
266 blockResolved = XmlSchemaDerivationMethod.Empty;
\r
269 blockResolved = schema.BlockDefault & XmlSchemaUtil.ComplexTypeBlockAllowed;
\r
274 if(Final != XmlSchemaDerivationMethod.None)
\r
276 if(Final == XmlSchemaDerivationMethod.All)
\r
277 finalResolved = XmlSchemaDerivationMethod.All;
\r
278 else if ((Final & XmlSchemaUtil.FinalAllowed) != Final)
\r
279 error (h, "Invalid final specification.");
\r
281 finalResolved = Final;
\r
285 switch (schema.FinalDefault) {
\r
286 case XmlSchemaDerivationMethod.All:
\r
287 finalResolved = XmlSchemaDerivationMethod.All;
\r
289 case XmlSchemaDerivationMethod.None:
\r
290 finalResolved = XmlSchemaDerivationMethod.Empty;
\r
293 finalResolved = schema.FinalDefault & XmlSchemaUtil.FinalAllowed;
\r
298 else // Not Top Level
\r
301 error(h,"abstract must be false in a local complex type");
\r
303 error(h,"name must be absent in a local complex type");
\r
304 if(Final != XmlSchemaDerivationMethod.None)
\r
305 error(h,"final must be absent in a local complex type");
\r
306 if(block != XmlSchemaDerivationMethod.None)
\r
307 error(h,"block must be absent in a local complex type");
\r
310 // Process contents and BaseSchemaType
\r
311 if(contentModel != null)
\r
313 if(anyAttribute != null || Attributes.Count != 0 || Particle != null)
\r
314 error(h,"attributes, particles or anyattribute is not allowed if ContentModel is present");
\r
315 errorCount += contentModel.Compile (h, schema);
\r
317 XmlSchemaSimpleContent smodel = ContentModel as XmlSchemaSimpleContent;
\r
320 XmlSchemaSimpleContentExtension sscx = smodel.Content as XmlSchemaSimpleContentExtension;
\r
321 if (sscx == null) {
\r
322 XmlSchemaSimpleContentRestriction sscr = smodel.Content as XmlSchemaSimpleContentRestriction;
\r
323 if (sscr != null) {
\r
324 if (sscr.BaseType != null) {
\r
325 sscr.BaseType.Compile (h, schema);
\r
326 BaseXmlSchemaTypeInternal = sscr.BaseType;
\r
334 if (Particle != null)
\r
335 errorCount += Particle.Compile (h, schema);
\r
337 if(this.anyAttribute != null)
\r
339 AnyAttribute.Compile(h,schema);
\r
341 foreach(XmlSchemaObject obj in Attributes)
\r
343 if(obj is XmlSchemaAttribute)
\r
345 XmlSchemaAttribute attr = (XmlSchemaAttribute) obj;
\r
346 errorCount += attr.Compile(h,schema);
\r
348 else if(obj is XmlSchemaAttributeGroupRef)
\r
350 XmlSchemaAttributeGroupRef atgrp = (XmlSchemaAttributeGroupRef) obj;
\r
351 errorCount += atgrp.Compile(h,schema);
\r
354 error(h,obj.GetType() +" is not valid in this place::ComplexType");
\r
358 XmlSchemaUtil.CompileID(Id, this, schema.IDCollection, h);
\r
359 this.CompilationId = schema.CompilationId;
\r
363 Guid CollectProcessId;
\r
365 private void CollectSchemaComponent (ValidationEventHandler h, XmlSchema schema)
\r
367 if (CollectProcessId == schema.CompilationId)
\r
369 // Below are already contributed by Compile():
\r
370 // {name}, {namespace} => QualifiedName, QNameInternal
\r
371 // {abstract} => ValidatedIsAbstract
\r
372 // {prohibited substitutions} => BlockResolved
\r
373 // {final} => FinalResolved
\r
374 // {annotations} => Annotation (XmlSchemaAnnotated)
\r
376 // Below are different properties depending on simpleContent | complexContent.
\r
377 // {base type definition}
\r
378 // {derivation method}
\r
379 // {attribute uses} => AttributeUses (later)
\r
380 // {attribute wildcard} => AttributeWildcard (later)
\r
384 // {base type definition} => baseSchemaTypeInternal (later)
\r
385 if (contentModel != null) {
\r
386 BaseSchemaTypeName = contentModel.Content != null ? contentModel.Content.GetBaseTypeName () : XmlQualifiedName.Empty;
\r
388 BaseXmlSchemaTypeInternal = schema.SchemaTypes [BaseSchemaTypeName] as XmlSchemaType;
\r
390 // Resolve redefine.
\r
391 if (this.isRedefineChild && BaseXmlSchemaType != null && this.QualifiedName == BaseSchemaTypeName) {
\r
392 XmlSchemaType redType = (XmlSchemaType) redefinedObject;
\r
393 if (redType == null)
\r
394 error (h, "Redefinition base type was not found.");
\r
396 BaseXmlSchemaTypeInternal = redType;
\r
399 // {derivation method} => resolvedDerivedBy
\r
400 if (contentModel != null && contentModel.Content != null) {
\r
401 resolvedDerivedBy =
\r
402 contentModel.Content.IsExtension ?
\r
403 XmlSchemaDerivationMethod.Extension :
\r
404 XmlSchemaDerivationMethod.Restriction;
\r
407 resolvedDerivedBy = XmlSchemaDerivationMethod.Empty;
\r
410 // {content type} => ContentType and ContentTypeParticle (later)
\r
411 if (ContentModel != null) {
\r
412 CollectContentTypeFromContentModel (h, schema);
\r
414 CollectContentTypeFromImmediateContent ();
\r
415 contentTypeParticle = validatableParticle.GetOptimizedParticle (true);
\r
416 if (contentTypeParticle == XmlSchemaParticle.Empty && resolvedContentType == XmlSchemaContentType.ElementOnly)
\r
417 resolvedContentType = XmlSchemaContentType.Empty;
\r
419 CollectProcessId = schema.CompilationId;
\r
422 #region {content type}
\r
423 private void CollectContentTypeFromImmediateContent ()
\r
425 // leave resolvedDerivedBy as Empty
\r
426 if (Particle != null)
\r
427 validatableParticle = Particle;
\r
428 if (this == AnyType) {
\r
429 resolvedContentType = XmlSchemaContentType.Mixed;
\r
433 if (validatableParticle == XmlSchemaParticle.Empty) {
\r
434 // note that this covers "Particle == null" case
\r
436 resolvedContentType = XmlSchemaContentType.TextOnly;
\r
438 resolvedContentType = XmlSchemaContentType.Empty;
\r
441 resolvedContentType = XmlSchemaContentType.Mixed;
\r
443 resolvedContentType = XmlSchemaContentType.ElementOnly;
\r
445 if (this != AnyType)
\r
446 BaseXmlSchemaTypeInternal = XmlSchemaComplexType.AnyType;
\r
449 private void CollectContentTypeFromContentModel (ValidationEventHandler h, XmlSchema schema)
\r
451 if (ContentModel.Content == null) {
\r
452 // basically it is error. Recover by specifying empty content.
\r
453 validatableParticle = XmlSchemaParticle.Empty;
\r
454 resolvedContentType = XmlSchemaContentType.Empty;
\r
458 if (ContentModel.Content is XmlSchemaComplexContentExtension)
\r
459 CollectContentTypeFromComplexExtension (h, schema);
\r
460 if (ContentModel.Content is XmlSchemaComplexContentRestriction)
\r
461 CollectContentTypeFromComplexRestriction ();
\r
464 private void CollectContentTypeFromComplexExtension (ValidationEventHandler h, XmlSchema schema)
\r
466 XmlSchemaComplexContentExtension cce = (XmlSchemaComplexContentExtension) ContentModel.Content;
\r
467 XmlSchemaComplexType baseComplexType = this.BaseXmlSchemaType as XmlSchemaComplexType;
\r
468 if (baseComplexType != null)
\r
469 baseComplexType.CollectSchemaComponent (h ,schema);
\r
471 // It must exist, but consider validation error case.
\r
472 if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
\r
473 baseComplexType = XmlSchemaComplexType.AnyType;
\r
475 // On error case, it simple reject any contents
\r
476 if (baseComplexType == null) {
\r
477 validatableParticle = XmlSchemaParticle.Empty;
\r
478 resolvedContentType = XmlSchemaContentType.Empty;
\r
482 // 3.4.2 complex content {content type}
\r
483 if (cce.Particle == null || cce.Particle == XmlSchemaParticle.Empty) {
\r
485 if (baseComplexType == null) {
\r
486 // Basically it is an error. Considering ValidationEventHandler.
\r
487 validatableParticle = XmlSchemaParticle.Empty;
\r
488 resolvedContentType = XmlSchemaContentType.Empty;
\r
490 validatableParticle = baseComplexType.ValidatableParticle;
\r
491 resolvedContentType = baseComplexType.resolvedContentType;
\r
493 } else if (baseComplexType.validatableParticle == XmlSchemaParticle.Empty
\r
494 || baseComplexType == XmlSchemaComplexType.AnyType) {
\r
496 validatableParticle = cce.Particle;
\r
497 resolvedContentType = GetComplexContentType (contentModel);
\r
499 // - 2.3 : create a new sequences that merges both contents.
\r
500 XmlSchemaSequence seq = new XmlSchemaSequence ();
\r
501 this.CopyInfo (seq);
\r
502 seq.Items.Add (baseComplexType.validatableParticle);
\r
503 seq.Items.Add (cce.Particle);
\r
504 seq.Compile (h, schema);
\r
505 seq.Validate (h, schema);
\r
506 validatableParticle = seq;
\r
507 resolvedContentType = GetComplexContentType (contentModel);
\r
509 if (validatableParticle == null)
\r
510 validatableParticle = XmlSchemaParticle.Empty;
\r
513 private void CollectContentTypeFromComplexRestriction ()
\r
515 XmlSchemaComplexContentRestriction ccr = (XmlSchemaComplexContentRestriction) ContentModel.Content;
\r
516 // 3.4.2 complex content schema component {content type}
\r
518 bool isEmptyParticle = false;
\r
519 if (ccr.Particle == null)
\r
520 isEmptyParticle = true;
\r
522 XmlSchemaGroupBase gb = ccr.Particle as XmlSchemaGroupBase;
\r
525 if (!(gb is XmlSchemaChoice) && gb.Items.Count == 0)
\r
526 isEmptyParticle = true;
\r
528 else if (gb is XmlSchemaChoice && gb.Items.Count == 0 && gb.ValidatedMinOccurs == 0)
\r
529 isEmptyParticle = true;
\r
532 if (isEmptyParticle) {
\r
533 resolvedContentType = XmlSchemaContentType.Empty;
\r
534 validatableParticle = XmlSchemaParticle.Empty;
\r
537 resolvedContentType = GetComplexContentType (contentModel);
\r
539 validatableParticle = ccr.Particle;
\r
543 // 3.4.2 Complex Content Schema Component {content type} 1.2.1
\r
544 private XmlSchemaContentType GetComplexContentType (XmlSchemaContentModel content)
\r
546 if (this.IsMixed || ((XmlSchemaComplexContent) content).IsMixed)
\r
547 return XmlSchemaContentType.Mixed;
\r
549 return XmlSchemaContentType.ElementOnly;
\r
554 // We have to validate:
\r
556 // - 3.4.3 Complex Type Definition Representation OK
\r
557 // - 3.4.6 Type Definition Properties Correct
\r
558 // - 3.4.6 Derivation Valid (Extension)
\r
559 // - 3.4.6 Derivation Valid (Restriction, Complex)
\r
561 // There are many schema errata:
\r
562 // http://www.w3.org/2001/05/xmlschema-errata#Errata1
\r
564 // E1-43 Derivation Valid (Restriction, Complex) 5.
\r
565 // E1-21 Derivation Valid (Restriction, Complex) 4.3.
\r
566 // E1-17 Type Derivation OK (Complex) 2.1.
\r
568 // And E1-38, E1-37, E1-30, E1-27
\r
570 internal override int Validate (ValidationEventHandler h, XmlSchema schema)
\r
572 if (IsValidated (schema.ValidationId))
\r
574 // FIXME: omitting it causes StackOverflowException
\r
575 // among the compilation of element and types, but
\r
576 // it may result in insufficient results.
\r
577 ValidationId = schema.ValidationId;
\r
579 CollectSchemaComponent (h, schema);
\r
581 // 3.4.6: Properties Correct
\r
582 // Term. 1 => 3.4.1 already done by CollectSchemaComponent()
\r
583 // except for {attribute uses} and {attribute wildcard}
\r
584 // Term. 2, 3 and 4 goes to ValidateContentModel().
\r
585 // Term. 5 follows in this method.
\r
587 if (ContentModel != null)
\r
588 ValidateContentModel (h, schema);
\r
590 if (Particle != null)
\r
591 ValidateImmediateParticle (h, schema);
\r
592 ValidateImmediateAttributes (h, schema);
\r
595 // Additional support for 3.8.6 All Group Limited
\r
596 if (ContentTypeParticle != null) {
\r
597 XmlSchemaAll termAll = contentTypeParticle.GetOptimizedParticle (true) as XmlSchemaAll;
\r
598 if (termAll != null && (termAll.ValidatedMaxOccurs != 1 || contentTypeParticle.ValidatedMaxOccurs != 1)) // here contentTypeParticle is used to check occurence.
\r
599 error (h, "Particle whose term is -all- and consists of complex type content particle must have maxOccurs = 1.");
\r
603 if (schema.Schemas.CompilationSettings != null &&
\r
604 schema.Schemas.CompilationSettings.EnableUpaCheck)
\r
606 // This check is optional only after 2.0
\r
607 contentTypeParticle.ValidateUniqueParticleAttribution (new XmlSchemaObjectTable (),
\r
608 new ArrayList (), h, schema);
\r
609 contentTypeParticle.ValidateUniqueTypeAttribution (
\r
610 new XmlSchemaObjectTable (), h, schema);
\r
612 // 3.4.6 Properties Correct :: 5 (Two distinct ID attributes)
\r
613 XmlSchemaAttribute idAttr = null;
\r
614 foreach (DictionaryEntry entry in attributeUses) {
\r
615 XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
\r
616 XmlSchemaDatatype dt = attr.AttributeType as XmlSchemaDatatype;
\r
617 if (dt != null && dt.TokenizedType != XmlTokenizedType.ID)
\r
620 dt = ((XmlSchemaSimpleType) attr.AttributeType).Datatype;
\r
621 if (dt != null && dt.TokenizedType == XmlTokenizedType.ID) {
\r
622 if (idAttr != null)
\r
623 error (h, "Two or more ID typed attribute declarations in a complex type are found.");
\r
629 ValidationId = schema.ValidationId;
\r
633 private void ValidateImmediateParticle (ValidationEventHandler h, XmlSchema schema)
\r
635 errorCount += particle.Validate (h, schema);
\r
636 XmlSchemaGroupRef pgrp = Particle as XmlSchemaGroupRef;
\r
637 if (pgrp != null) {
\r
638 if (pgrp.TargetGroup != null)
\r
639 errorCount += pgrp.TargetGroup.Validate (h,schema);
\r
640 // otherwise, it might be missing sub components.
\r
641 else if (!schema.IsNamespaceAbsent (pgrp.RefName.Namespace))
\r
642 error (h, "Referenced group " + pgrp.RefName + " was not found in the corresponding schema.");
\r
646 private void ValidateImmediateAttributes (ValidationEventHandler h, XmlSchema schema)
\r
648 // {attribute uses}
\r
649 // also checks 3.4.6 Properties Correct :: 4 (Distinct attributes)
\r
650 attributeUses = new XmlSchemaObjectTable ();
\r
651 XmlSchemaUtil.ValidateAttributesResolved (attributeUses,
\r
652 h, schema, attributes, anyAttribute, ref attributeWildcard, null, false);
\r
655 private void ValidateContentModel (ValidationEventHandler h, XmlSchema schema)
\r
657 XmlSchemaType baseType = BaseXmlSchemaTypeInternal;
\r
659 // Here we check 3.4.6 Properties Correct :: 2. and 3.
\r
660 errorCount += contentModel.Validate (h, schema);
\r
661 XmlSchemaComplexContentExtension cce = contentModel.Content as XmlSchemaComplexContentExtension;
\r
662 XmlSchemaComplexContentRestriction ccr = contentModel.Content as XmlSchemaComplexContentRestriction;
\r
663 XmlSchemaSimpleContentExtension sce = contentModel.Content as XmlSchemaSimpleContentExtension;
\r
664 XmlSchemaSimpleContentRestriction scr = contentModel.Content as XmlSchemaSimpleContentRestriction;
\r
666 XmlSchemaAnyAttribute localAnyAttribute = null;
\r
667 XmlSchemaAnyAttribute baseAnyAttribute = null;
\r
669 // 3.4.6 Properties Correct :: 3. Circular definition prohibited.
\r
670 if (ValidateRecursionCheck ())
\r
671 error (h, "Circular definition of schema types was found.");
\r
672 if (baseType != null) {
\r
673 baseType.Validate (h, schema);
\r
674 // Fill "Datatype" property.
\r
675 this.DatatypeInternal = baseType.Datatype;
\r
676 } else if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
\r
677 DatatypeInternal = XmlSchemaSimpleType.AnySimpleType;
678 else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {
\r
679 DatatypeInternal = XmlSchemaDatatype.FromName (BaseSchemaTypeName);
\r
682 XmlSchemaComplexType baseComplexType = baseType as XmlSchemaComplexType;
\r
683 XmlSchemaSimpleType baseSimpleType = baseType as XmlSchemaSimpleType;
\r
685 // 3.4.6 Derivation Valid (common to Extension and Restriction, Complex) :: 1.
\r
686 if (baseType != null && (baseType.FinalResolved & resolvedDerivedBy) != 0)
\r
687 error (h, "Specified derivation is specified as final by derived schema type.");
\r
689 // 3.4.6 Properties Correct :: 2.
\r
690 // Simple {base type definition} and restriction {derivation method} not allowed.
\r
691 if (baseSimpleType != null && resolvedDerivedBy == XmlSchemaDerivationMethod.Restriction)
\r
692 error (h, "If the base schema type is a simple type, then this type must be extension.");
\r
694 // Common to complexContent
\r
695 if (cce != null || ccr != null) {
\r
696 // 3.4.3 Complex Type Definition Representation OK :: 1.
\r
698 if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
\r
699 baseComplexType = XmlSchemaComplexType.AnyType;
\r
700 else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName))
\r
701 error (h, "Referenced base schema type is XML Schema datatype.");
\r
702 else if (baseComplexType == null && !schema.IsNamespaceAbsent (BaseSchemaTypeName.Namespace))
\r
703 error (h, "Referenced base schema type " + BaseSchemaTypeName + " was not complex type or not found in the corresponding schema.");
\r
705 // Common to simpleContent
\r
707 // ContentType of {content type}
\r
708 resolvedContentType = XmlSchemaContentType.TextOnly;
\r
710 // 3.4.3 Complex Type Definition Representation OK :: 1.
\r
712 if (BaseSchemaTypeName == XmlSchemaComplexType.AnyTypeName)
\r
713 baseComplexType = XmlSchemaComplexType.AnyType;
715 if (baseComplexType != null && baseComplexType.ContentType != XmlSchemaContentType.TextOnly) {
\r
716 error (h, "Base schema complex type of a simple content must be simple content type. Base type is " + BaseSchemaTypeName);
\r
717 } else if (sce == null && (baseSimpleType != null && BaseSchemaTypeName.Namespace != XmlSchema.Namespace)) {
\r
718 error (h, "If a simple content is not an extension, base schema type must be complex type. Base type is " + BaseSchemaTypeName);
\r
719 } else if (XmlSchemaUtil.IsBuiltInDatatypeName (BaseSchemaTypeName)) {
\r
720 // do nothing for particle.
\r
722 // otherwise, it might be missing sub components.
\r
723 else if (baseType == null && !schema.IsNamespaceAbsent (BaseSchemaTypeName.Namespace))
\r
724 error (h, "Referenced base schema type " + BaseSchemaTypeName + " was not found in the corresponding schema.");
\r
726 // 3.4.3 Complex Type Definition Representation OK :: 2.
\r
727 // Note that baseSimpleType is also allowed as to Errata E1-27 (http://www.w3.org/2001/05/xmlschema-errata)
\r
728 if (baseComplexType != null) {
\r
729 if (baseComplexType.ContentType == XmlSchemaContentType.TextOnly) {
\r
731 // Here "baseComplexType.Particle != null" is required for error-ignorant case
\r
732 } else if (scr != null && baseComplexType.ContentType == XmlSchemaContentType.Mixed && baseComplexType.Particle != null && baseComplexType.Particle.ValidateIsEmptiable () && scr.BaseType != null) {
\r
733 // 2.1.2 && 2.2: OK
\r
736 error (h, "Base complex type of a simple content restriction must be text only.");
\r
738 if (sce != null && baseComplexType == null) {
\r
742 error (h, "Not allowed base type of a simple content restriction.");
\r
746 // complexType/complexContent/extension
\r
748 // I don't think 3.4.6 Derivation Valid (Extension) :: 1.2
\r
749 // is constraining anything here, since 3.4.2 {attribute uses}
\r
750 // defines as to include base type's attribute uses.
\r
751 localAnyAttribute = cce.AnyAttribute;
\r
752 if (baseComplexType != null) {
\r
753 foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
\r
754 XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
\r
755 XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
\r
757 baseAnyAttribute = baseComplexType.AttributeWildcard;
\r
760 errorCount += XmlSchemaUtil.ValidateAttributesResolved (
\r
761 this.attributeUses, h, schema, cce.Attributes,
\r
762 cce.AnyAttribute , ref attributeWildcard, null, true);
\r
764 // After adding them, test extension validity.
\r
765 if (baseComplexType != null)
\r
766 this.ValidateComplexBaseDerivationValidExtension (baseComplexType, h, schema);
\r
767 else if (baseSimpleType != null)
\r
768 this.ValidateSimpleBaseDerivationValidExtension (baseSimpleType, h, schema);
\r
770 // complexType/complexContent/restriction
\r
772 // For ValidationEventHandler.
\r
773 if (baseComplexType == null)
\r
774 baseComplexType = XmlSchemaComplexType.AnyType;
\r
775 if (ccr.Particle != null)
\r
776 ccr.Particle.Validate (h, schema);
\r
779 localAnyAttribute = ccr.AnyAttribute;
\r
780 this.attributeWildcard = localAnyAttribute;
\r
781 if (baseComplexType != null)
\r
782 baseAnyAttribute = baseComplexType.AttributeWildcard;
\r
783 if (baseAnyAttribute != null && localAnyAttribute != null)
\r
784 // 1.3 attribute wildcard subset. (=> 3.10.6)
\r
785 localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
\r
787 // 3.4.2 Complex Type Definition with complex content Schema Component
\r
788 // and its {attribute uses} and {attribute wildcard} are done here (descendantly)
\r
789 errorCount += XmlSchemaUtil.ValidateAttributesResolved (
\r
790 this.attributeUses, h, schema, ccr.Attributes,
\r
791 ccr.AnyAttribute, ref attributeWildcard, null, false);
\r
792 foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
\r
793 XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
\r
794 if (attributeUses [attr.QualifiedName] == null)
\r
795 XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
\r
798 // Derivation Valid (Restriction, Complex) :: 5.
\r
799 // Also see E1-15 of http://www.w3.org/2001/05/xmlschema-errata#Errata1
\r
800 // 5.1 shouled be in scr (XmlSchemaSimpleContentRestriction)
\r
801 this.ValidateDerivationValidRestriction (baseComplexType, h, schema);
\r
803 // complexType/simpleContent/extension
\r
805 errorCount += XmlSchemaUtil.ValidateAttributesResolved (
\r
806 this.attributeUses, h, schema, sce.Attributes,
\r
807 sce.AnyAttribute, ref attributeWildcard, null, true);
\r
810 // I don't think 3.4.6 Derivation Valid (Extension) :: 1.2
\r
811 // is constraining anything here, since 3.4.2 {attribute uses}
\r
812 // defines as to include base type's attribute uses.
\r
813 localAnyAttribute = sce.AnyAttribute;
\r
815 if (baseComplexType != null) {
\r
816 baseAnyAttribute = baseComplexType.AttributeWildcard;
\r
818 foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
\r
819 XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
\r
820 #if BUGGY_MS_COMPLIANT
\r
821 if (attr.Use != XmlSchemaUse.Prohibited)
\r
822 XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
\r
824 XmlSchemaUtil.AddToTable (attributeUses, attr, attr.QualifiedName, h);
\r
827 if (baseAnyAttribute != null && localAnyAttribute != null)
\r
828 // 1.3 attribute wildcard subset. (=> 3.10.6)
\r
829 localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
\r
831 // complexType/simpleContent/restriction
\r
834 baseAnyAttribute = baseComplexType != null ? baseComplexType.AttributeWildcard : null;
\r
836 localAnyAttribute = scr.AnyAttribute;
\r
837 if (localAnyAttribute != null && baseAnyAttribute != null)
\r
838 // 1.3 attribute wildcard subset. (=> 3.10.6)
\r
839 localAnyAttribute.ValidateWildcardSubset (baseAnyAttribute, h, schema);
\r
840 // 3.4.6 :: 5.1. Beware that There is an errata for 5.1!!
\r
841 // http://www.w3.org/2001/05/xmlschema-errata#Errata1
\r
843 // 3.4.2 Complex Type Definition with simple content Schema Component
\r
844 // and its {attribute uses} and {attribute wildcard} are done here (descendantly)
\r
845 errorCount += XmlSchemaUtil.ValidateAttributesResolved (
\r
846 this.attributeUses, h, schema, scr.Attributes,
\r
847 scr.AnyAttribute, ref attributeWildcard, null, false);
\r
850 // Common process of AttributeWildcard.
\r
851 if (localAnyAttribute != null) {
\r
852 this.attributeWildcard = localAnyAttribute;
\r
855 this.attributeWildcard = baseAnyAttribute;
\r
858 // 3.4.6 Type Derivation OK (Complex)
\r
859 internal void ValidateTypeDerivationOK (object b, ValidationEventHandler h, XmlSchema schema)
\r
861 // AnyType derives from AnyType itself.
\r
862 if (this == XmlSchemaComplexType.AnyType && BaseXmlSchemaType == this)
\r
865 XmlSchemaType bst = b as XmlSchemaType;
\r
866 if (b == this) // 1 and 2.1
\r
868 if (bst != null && (resolvedDerivedBy & bst.FinalResolved) != 0) // 1.
\r
869 error (h, "Derivation type " + resolvedDerivedBy + " is prohibited by the base type.");
\r
870 // FIXME: here BaseSchemaType should be
\r
871 // BaseXmlSchemaType, however for some case it
\r
872 // seems not working.
\r
873 if (BaseSchemaType == b) // 2.2
\r
875 if (BaseSchemaType == null || BaseXmlSchemaType == XmlSchemaComplexType.AnyType) { // 2.3.1
\r
876 error (h, "Derived type's base schema type is anyType.");
\r
880 XmlSchemaComplexType dbct = BaseXmlSchemaType as XmlSchemaComplexType;
\r
881 if (dbct != null) {
\r
882 dbct.ValidateTypeDerivationOK (b, h, schema);
\r
886 XmlSchemaSimpleType dbst = BaseXmlSchemaType as XmlSchemaSimpleType;
\r
887 if (dbst != null) {
\r
888 dbst.ValidateTypeDerivationOK (b, h, schema, true);
\r
893 // 3.4.6 Derivation Valid (Extension) - Term. 1 (Complex Type)
\r
894 internal void ValidateComplexBaseDerivationValidExtension (XmlSchemaComplexType baseComplexType,
\r
895 ValidationEventHandler h, XmlSchema schema)
\r
898 if ((baseComplexType.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0)
\r
899 error (h, "Derivation by extension is prohibited.");
\r
901 foreach (DictionaryEntry entry in baseComplexType.AttributeUses) {
\r
902 XmlSchemaAttribute ba = (XmlSchemaAttribute) entry.Value;
\r
903 XmlSchemaAttribute da = AttributeUses [ba.QualifiedName] as XmlSchemaAttribute;
\r
905 error (h, "Invalid complex type derivation by extension was found. Missing attribute was found: " + ba.QualifiedName + " .");
\r
907 // 1.3 -> 3.10.6 Wildcard Subset.
\r
908 if (AnyAttribute != null) {
\r
909 if (baseComplexType.AnyAttribute == null)
\r
910 error (h, "Invalid complex type derivation by extension was found. Base complex type does not have an attribute wildcard.");
\r
912 baseComplexType.AnyAttribute.ValidateWildcardSubset (AnyAttribute, h, schema);
\r
915 // 1.4 => 1.4.2 (1.4.1 would be included in SimpleContentExtention).
\r
917 // if (contentTypeParticle == null)
\r
918 // error (h, "Extended complex type's content type must not be empty.");
\r
920 if (baseComplexType.ContentType != XmlSchemaContentType.Empty) {
\r
922 if (this.ContentType != baseComplexType.ContentType)
\r
923 // if (this.GetContentType (false) != baseComplexType.GetContentType (false))
\r
924 error (h, "Base complex type has different content type " + baseComplexType.ContentType + ".");
\r
925 // 1.4.2.2.2.2 => 3.9.6 Particle Valid (Extension)
\r
926 else if (this.contentTypeParticle == null ||
\r
927 !this.contentTypeParticle.ParticleEquals (baseComplexType.ContentTypeParticle)) {
\r
928 XmlSchemaSequence seq = contentTypeParticle as XmlSchemaSequence;
\r
929 if (contentTypeParticle != XmlSchemaParticle.Empty && (seq == null || contentTypeParticle.ValidatedMinOccurs != 1 || contentTypeParticle.ValidatedMaxOccurs != 1))
\r
930 error (h, "Invalid complex content extension was found.");
\r
932 // Identical sequence item should be checked, but
\r
933 // I think it is naturally achieved as coded above.
\r
939 // 3.4.6 Derivation Valid (Extension) - Term. 2 (Simple Type)
\r
940 internal void ValidateSimpleBaseDerivationValidExtension (object baseType,
\r
941 ValidationEventHandler h, XmlSchema schema)
\r
943 XmlSchemaSimpleType st = baseType as XmlSchemaSimpleType;
\r
944 if (st != null && (st.FinalResolved & XmlSchemaDerivationMethod.Extension) != 0)
\r
945 error (h, "Extension is prohibited by the base type.");
\r
947 XmlSchemaDatatype dt = baseType as XmlSchemaDatatype;
\r
950 if (dt != this.Datatype)
\r
951 error (h, "To extend simple type, a complex type must have the same content type as the base type.");
\r
954 internal void ValidateDerivationValidRestriction (XmlSchemaComplexType baseType,
\r
955 ValidationEventHandler h, XmlSchema schema)
\r
958 if (baseType == null) {
\r
959 error (h, "Base schema type is not a complex type.");
\r
962 if ((baseType.FinalResolved & XmlSchemaDerivationMethod.Restriction) != 0) {
\r
963 error (h, "Prohibited derivation by restriction by base schema type.");
\r
968 foreach (DictionaryEntry entry in this.AttributeUses) {
\r
969 XmlSchemaAttribute attr = (XmlSchemaAttribute) entry.Value;
\r
970 XmlSchemaAttribute baseAttr = baseType.AttributeUses [attr.QualifiedName] as XmlSchemaAttribute;
\r
971 if (baseAttr != null) {
\r
974 if (baseAttr.ValidatedUse != XmlSchemaUse.Optional && attr.ValidatedUse != XmlSchemaUse.Required)
\r
975 error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
\r
977 XmlSchemaSimpleType attrSimpleType = attr.AttributeType as XmlSchemaSimpleType;
\r
978 XmlSchemaSimpleType baseAttrSimpleType = baseAttr.AttributeType as XmlSchemaSimpleType;
\r
979 bool typeError = false;
\r
980 if (attrSimpleType != null)
\r
981 attrSimpleType.ValidateDerivationValid (baseAttrSimpleType, null, h, schema);
\r
982 else if (attrSimpleType == null && baseAttrSimpleType != null)
\r
985 Type t1 = attr.AttributeType.GetType ();
\r
986 Type t2 = baseAttr.AttributeType.GetType ();
\r
987 if (t1 != t2 && t1.IsSubclassOf (t2))
\r
991 error (h, "Invalid attribute derivation by restriction because of its type: " + attr.QualifiedName + " .");
\r
993 if (baseAttr.ValidatedFixedValue != null && attr.ValidatedFixedValue != baseAttr.ValidatedFixedValue)
\r
994 error (h, "Invalid attribute derivation by restriction because of its fixed value constraint: " + attr.QualifiedName + " .");
\r
997 if (baseType.AttributeWildcard != null)
\r
998 if (!baseType.AttributeWildcard.ValidateWildcardAllowsNamespaceName (
\r
999 attr.QualifiedName.Namespace, schema) &&
\r
1000 !schema.IsNamespaceAbsent (attr.QualifiedName.Namespace))
\r
1001 error (h, "Invalid attribute derivation by restriction was found for " + attr.QualifiedName + " .");
\r
1004 // I think 3. is considered in 2.
\r
1006 if (this.AttributeWildcard != null && baseType != XmlSchemaComplexType.AnyType) {
\r
1007 if (baseType.AttributeWildcard == null)
\r
1008 error (h, "Invalid attribute derivation by restriction because of attribute wildcard.");
\r
1010 AttributeWildcard.ValidateWildcardSubset (baseType.AttributeWildcard, h, schema);
\r
1014 if (this == AnyType)
\r
1016 if (contentTypeParticle == XmlSchemaParticle.Empty) {
\r
1018 if (ContentType != XmlSchemaContentType.Empty) {
\r
1020 // XmlSchemaSimpleType baseST = baseType as XmlSchemaSimpleType;
\r
1022 if (baseType.ContentType == XmlSchemaContentType.Mixed && !baseType.ContentTypeParticle.ValidateIsEmptiable ())
\r
1023 error (h, "Invalid content type derivation.");
\r
1027 if (baseType.ContentTypeParticle != XmlSchemaParticle.Empty &&
\r
1028 !baseType.ContentTypeParticle.ValidateIsEmptiable ())
\r
1029 error (h, "Invalid content type derivation.");
\r
1032 // 5.3 => 3.9.6 Particle Valid (Restriction)
\r
1033 if (baseType.ContentTypeParticle != null) {
\r
1034 // 3.9.6 - 1 : same particle.
\r
1035 // 3.9.6 - 2 is covered by using ActualParticle.
\r
1036 if (!contentTypeParticle.ParticleEquals (baseType.ContentTypeParticle))
\r
1037 contentTypeParticle.ValidateDerivationByRestriction (baseType.ContentTypeParticle, h, schema, true);
\r
1044 // abstract = boolean : false
\r
1045 // block = (#all | List of (extension | restriction))
\r
1046 // final = (#all | List of (extension | restriction))
\r
1048 // mixed = boolean : false
\r
1050 // {any attributes with non-schema namespace . . .}>
\r
1051 // Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))
\r
1053 internal static XmlSchemaComplexType Read(XmlSchemaReader reader, ValidationEventHandler h)
\r
1055 XmlSchemaComplexType ctype = new XmlSchemaComplexType();
\r
1056 reader.MoveToElement();
\r
1057 Exception innerex;
\r
1059 if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
\r
1061 error(h,"Should not happen :1: XmlSchemaComplexType.Read, name="+reader.Name,null);
\r
1062 reader.SkipToEnd();
\r
1066 ctype.LineNumber = reader.LineNumber;
\r
1067 ctype.LinePosition = reader.LinePosition;
\r
1068 ctype.SourceUri = reader.BaseURI;
\r
1070 while(reader.MoveToNextAttribute())
\r
1072 if(reader.Name == "abstract")
\r
1074 ctype.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
\r
1075 if(innerex != null)
\r
1076 error(h,reader.Value + " is invalid value for abstract",innerex);
\r
1078 else if(reader.Name == "block")
\r
1080 ctype.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block",
\r
1081 XmlSchemaUtil.ComplexTypeBlockAllowed);
\r
1082 if(innerex != null)
\r
1083 error (h,"some invalid values for block attribute were found",innerex);
\r
1085 else if(reader.Name == "final")
\r
1087 ctype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "final",
\r
1088 XmlSchemaUtil.FinalAllowed);
\r
1089 if(innerex != null)
\r
1090 error (h,"some invalid values for final attribute were found",innerex);
\r
1092 else if(reader.Name == "id")
\r
1094 ctype.Id = reader.Value;
\r
1096 else if(reader.Name == "mixed")
\r
1098 ctype.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex);
\r
1099 if(innerex != null)
\r
1100 error(h,reader.Value + " is invalid value for mixed",innerex);
\r
1102 else if(reader.Name == "name")
\r
1104 ctype.Name = reader.Value;
\r
1106 else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
\r
1108 error(h,reader.Name + " is not a valid attribute for complexType",null);
\r
1112 XmlSchemaUtil.ReadUnhandledAttribute(reader,ctype);
\r
1116 reader.MoveToElement();
\r
1117 if(reader.IsEmptyElement)
\r
1120 //Content: 1. annotation?,
\r
1121 // 2. simpleContent | 2. complexContent |
\r
1122 // (3.(group | all | choice | sequence)?, (4.(attribute | attributeGroup)*, 5.anyAttribute?)))
\r
1124 while(reader.ReadNextElement())
\r
1126 if(reader.NodeType == XmlNodeType.EndElement)
\r
1128 if(reader.LocalName != xmlname)
\r
1129 error(h,"Should not happen :2: XmlSchemaComplexType.Read, name="+reader.Name,null);
\r
1132 if(level <= 1 && reader.LocalName == "annotation")
\r
1134 level = 2; //Only one annotation
\r
1135 XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h);
\r
1136 if(annotation != null)
\r
1137 ctype.Annotation = annotation;
\r
1142 if(reader.LocalName == "simpleContent")
\r
1145 XmlSchemaSimpleContent simple = XmlSchemaSimpleContent.Read(reader,h);
\r
1146 if(simple != null)
\r
1147 ctype.ContentModel = simple;
\r
1150 if(reader.LocalName == "complexContent")
\r
1153 XmlSchemaComplexContent complex = XmlSchemaComplexContent.Read(reader,h);
\r
1154 if(complex != null)
\r
1155 ctype.contentModel = complex;
\r
1161 if(reader.LocalName == "group")
\r
1164 XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h);
\r
1166 ctype.particle = group;
\r
1169 if(reader.LocalName == "all")
\r
1172 XmlSchemaAll all = XmlSchemaAll.Read(reader,h);
\r
1174 ctype.particle = all;
\r
1177 if(reader.LocalName == "choice")
\r
1180 XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h);
\r
1181 if(choice != null)
\r
1182 ctype.particle = choice;
\r
1185 if(reader.LocalName == "sequence")
\r
1188 XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h);
\r
1189 if(sequence != null)
\r
1190 ctype.particle = sequence;
\r
1196 if(reader.LocalName == "attribute")
\r
1199 XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h);
\r
1201 ctype.Attributes.Add(attr);
\r
1204 if(reader.LocalName == "attributeGroup")
\r
1207 XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h);
\r
1209 ctype.attributes.Add(attr);
\r
1213 if(level <= 5 && reader.LocalName == "anyAttribute")
\r
1216 XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h);
\r
1217 if(anyattr != null)
\r
1218 ctype.AnyAttribute = anyattr;
\r
1221 reader.RaiseInvalidElementError();
\r