internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent xmlSchemaSimpleContent = new XmlSchemaSimpleContent(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "simpleContent") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaSimpleContent.LineNumber = reader.LineNumber; xmlSchemaSimpleContent.LinePosition = reader.LinePosition; xmlSchemaSimpleContent.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaSimpleContent.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 simpleContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleContent); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleContent); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "simpleContent") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleContent.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleContent.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "restriction") { num = 3; XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = XmlSchemaSimpleContentRestriction.Read(reader, h); if (xmlSchemaSimpleContentRestriction != null) { xmlSchemaSimpleContent.content = xmlSchemaSimpleContentRestriction; } continue; } if (reader.LocalName == "extension") { num = 3; XmlSchemaSimpleContentExtension xmlSchemaSimpleContentExtension = XmlSchemaSimpleContentExtension.Read(reader, h); if (xmlSchemaSimpleContentExtension != null) { xmlSchemaSimpleContent.content = xmlSchemaSimpleContentExtension; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleContent); }
//<simpleContent // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</simpleContent> internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } simple.LineNumber = reader.LineNumber; simple.LinePosition = reader.LinePosition; simple.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { simple.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for simpleContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, simple); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(simple); } //Content: (annotation?, (restriction | extension)) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleContent.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) { simple.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader, h); if (restriction != null) { simple.content = restriction; } continue; } if (reader.LocalName == "extension") { level = 3; XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader, h); if (extension != null) { simple.content = extension; } continue; } } reader.RaiseInvalidElementError(); } return(simple); }