//<extension // base = QName // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) //</extension> internal static XmlSchemaComplexContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentExtension extension = new XmlSchemaComplexContentExtension(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); reader.Skip(); return(null); } extension.LineNumber = reader.LineNumber; extension.LinePosition = reader.LinePosition; extension.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception innerex; extension.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for base attribute", innerex); } } else if (reader.Name == "id") { extension.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for extension", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, extension); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(extension); } //Content: 1. annotation?, // (2.(group | all | choice | sequence)?, (3.(attribute | attributeGroup)*, 4.anyAttribute?))) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { extension.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "group") { level = 3; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader, h); if (group != null) { extension.particle = group; } continue; } if (reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader, h); if (all != null) { extension.particle = all; } continue; } if (reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader, h); if (choice != null) { extension.particle = choice; } continue; } if (reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader, h); if (sequence != null) { extension.particle = sequence; } continue; } } if (level <= 3) { if (reader.LocalName == "attribute") { level = 3; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { extension.Attributes.Add(attr); } continue; } if (reader.LocalName == "attributeGroup") { level = 3; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader, h); if (attr != null) { extension.attributes.Add(attr); } continue; } } if (level <= 4 && reader.LocalName == "anyAttribute") { level = 5; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader, h); if (anyattr != null) { extension.AnyAttribute = anyattr; } continue; } reader.RaiseInvalidElementError(); } return(extension); }
//<choice // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (element | group | choice | sequence | any)*) //</choice> internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaChoice choice = new XmlSchemaChoice(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaChoice.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } choice.LineNumber = reader.LineNumber; choice.LinePosition = reader.LinePosition; choice.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { choice.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { choice.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { choice.MinOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for minOccurs", e); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for choice", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, choice); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(choice); } // Content: (annotation?, (element | group | choice | sequence | any)*) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaChoice.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { choice.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { choice.items.Add(element); } continue; } if (reader.LocalName == "group") { level = 2; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader, h); if (group != null) { choice.items.Add(group); } continue; } if (reader.LocalName == "choice") { level = 2; XmlSchemaChoice ch = XmlSchemaChoice.Read(reader, h); if (ch != null) { choice.items.Add(ch); } continue; } if (reader.LocalName == "sequence") { level = 2; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader, h); if (sequence != null) { choice.items.Add(sequence); } continue; } if (reader.LocalName == "any") { level = 2; XmlSchemaAny any = XmlSchemaAny.Read(reader, h); if (any != null) { choice.items.Add(any); } continue; } } reader.RaiseInvalidElementError(); } return(choice); }
internal static XmlSchemaComplexContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension = new XmlSchemaComplexContentExtension(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "extension") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaComplexContentExtension.LineNumber = reader.LineNumber; xmlSchemaComplexContentExtension.LinePosition = reader.LinePosition; xmlSchemaComplexContentExtension.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception ex; xmlSchemaComplexContentExtension.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for base attribute", ex); } } else if (reader.Name == "id") { xmlSchemaComplexContentExtension.Id = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for extension", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaComplexContentExtension); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaComplexContentExtension); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "extension") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaComplexContentExtension.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "group") { num = 3; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaGroupRef; } continue; } if (reader.LocalName == "all") { num = 3; XmlSchemaAll xmlSchemaAll = XmlSchemaAll.Read(reader, h); if (xmlSchemaAll != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaAll; } continue; } if (reader.LocalName == "choice") { num = 3; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaChoice; } continue; } if (reader.LocalName == "sequence") { num = 3; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaSequence; } continue; } } if (num <= 3) { if (reader.LocalName == "attribute") { num = 3; XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h); if (xmlSchemaAttribute != null) { xmlSchemaComplexContentExtension.Attributes.Add(xmlSchemaAttribute); } continue; } if (reader.LocalName == "attributeGroup") { num = 3; XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h); if (xmlSchemaAttributeGroupRef != null) { xmlSchemaComplexContentExtension.attributes.Add(xmlSchemaAttributeGroupRef); } continue; } } if (num <= 4 && reader.LocalName == "anyAttribute") { num = 5; XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h); if (xmlSchemaAnyAttribute != null) { xmlSchemaComplexContentExtension.AnyAttribute = xmlSchemaAnyAttribute; } } else { reader.RaiseInvalidElementError(); } } } return(xmlSchemaComplexContentExtension); }
internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaChoice xmlSchemaChoice = new XmlSchemaChoice(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "choice") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaChoice.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaChoice.LineNumber = reader.LineNumber; xmlSchemaChoice.LinePosition = reader.LinePosition; xmlSchemaChoice.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaChoice.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { xmlSchemaChoice.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaChoice.MinOccursString = reader.Value; } catch (Exception innerException2) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for minOccurs", innerException2); } } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for choice", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaChoice); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaChoice); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "choice") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaChoice.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaChoice.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "element") { num = 2; XmlSchemaElement xmlSchemaElement = XmlSchemaElement.Read(reader, h); if (xmlSchemaElement != null) { xmlSchemaChoice.items.Add(xmlSchemaElement); } continue; } if (reader.LocalName == "group") { num = 2; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaChoice.items.Add(xmlSchemaGroupRef); } continue; } if (reader.LocalName == "choice") { num = 2; XmlSchemaChoice xmlSchemaChoice2 = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice2 != null) { xmlSchemaChoice.items.Add(xmlSchemaChoice2); } continue; } if (reader.LocalName == "sequence") { num = 2; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaChoice.items.Add(xmlSchemaSequence); } continue; } if (reader.LocalName == "any") { num = 2; XmlSchemaAny xmlSchemaAny = XmlSchemaAny.Read(reader, h); if (xmlSchemaAny != null) { xmlSchemaChoice.items.Add(xmlSchemaAny); } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaChoice); }