//<redefine // id = ID // schemaLocation = anyURI // {any attributes with non-schema namespace . . .}> // Content: (annotation | (simpleType | complexType | group | attributeGroup))* //</redefine> internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaRedefine redefine = new XmlSchemaRedefine(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaRedefine.Read, name=" + reader.Name, null); reader.Skip(); return(null); } redefine.LineNumber = reader.LineNumber; redefine.LinePosition = reader.LinePosition; redefine.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { redefine.Id = reader.Value; } else if (reader.Name == "schemaLocation") { redefine.SchemaLocation = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for redefine", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, redefine); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(redefine); } //(annotation | (simpleType | complexType | group | attributeGroup))* while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaRedefine.Read, name=" + reader.Name, null); } break; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { redefine.items.Add(annotation); } continue; } if (reader.LocalName == "simpleType") { XmlSchemaSimpleType simpleType = XmlSchemaSimpleType.Read(reader, h); if (simpleType != null) { redefine.items.Add(simpleType); } continue; } if (reader.LocalName == "complexType") { XmlSchemaComplexType complexType = XmlSchemaComplexType.Read(reader, h); if (complexType != null) { redefine.items.Add(complexType); } continue; } if (reader.LocalName == "group") { XmlSchemaGroup group = XmlSchemaGroup.Read(reader, h); if (group != null) { redefine.items.Add(group); } continue; } if (reader.LocalName == "attributeGroup") { XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader, h); if (attributeGroup != null) { redefine.items.Add(attributeGroup); } continue; } reader.RaiseInvalidElementError(); } return(redefine); }
private static void ReadContent(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h) { reader.MoveToElement(); if (reader.LocalName != "schema" && reader.NamespaceURI != XmlSchema.Namespace && reader.NodeType != XmlNodeType.Element) { error(h, "UNREACHABLE CODE REACHED: Method: Schema.ReadContent, " + reader.LocalName + ", " + reader.NamespaceURI, null); } //(include | import | redefine | annotation)*, //((simpleType | complexType | group | attributeGroup | element | attribute | notation | annotation)* int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchema.Read, name=" + reader.Name, null); } break; } if (level <= 1) { if (reader.LocalName == "include") { XmlSchemaInclude include = XmlSchemaInclude.Read(reader, h); if (include != null) { schema.includes.Add(include); } continue; } if (reader.LocalName == "import") { XmlSchemaImport import = XmlSchemaImport.Read(reader, h); if (import != null) { schema.includes.Add(import); } continue; } if (reader.LocalName == "redefine") { XmlSchemaRedefine redefine = XmlSchemaRedefine.Read(reader, h); if (redefine != null) { schema.includes.Add(redefine); } continue; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { schema.items.Add(annotation); } continue; } } if (level <= 2) { level = 2; if (reader.LocalName == "simpleType") { XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { schema.items.Add(stype); } continue; } if (reader.LocalName == "complexType") { XmlSchemaComplexType ctype = XmlSchemaComplexType.Read(reader, h); if (ctype != null) { schema.items.Add(ctype); } continue; } if (reader.LocalName == "group") { XmlSchemaGroup group = XmlSchemaGroup.Read(reader, h); if (group != null) { schema.items.Add(group); } continue; } if (reader.LocalName == "attributeGroup") { XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader, h); if (attributeGroup != null) { schema.items.Add(attributeGroup); } continue; } if (reader.LocalName == "element") { XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { schema.items.Add(element); } continue; } if (reader.LocalName == "attribute") { XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { schema.items.Add(attr); } continue; } if (reader.LocalName == "notation") { XmlSchemaNotation notation = XmlSchemaNotation.Read(reader, h); if (notation != null) { schema.items.Add(notation); } continue; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { schema.items.Add(annotation); } continue; } } reader.RaiseInvalidElementError(); } }
internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaRedefine xmlSchemaRedefine = new XmlSchemaRedefine(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "redefine") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaRedefine.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaRedefine.LineNumber = reader.LineNumber; xmlSchemaRedefine.LinePosition = reader.LinePosition; xmlSchemaRedefine.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaRedefine.Id = reader.Value; } else if (reader.Name == "schemaLocation") { xmlSchemaRedefine.SchemaLocation = 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 redefine", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaRedefine); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaRedefine); } while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "redefine") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaRedefine.Read, name=" + reader.Name, null); } break; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaRedefine.items.Add(xmlSchemaAnnotation); } } else if (reader.LocalName == "simpleType") { XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaRedefine.items.Add(xmlSchemaSimpleType); } } else if (reader.LocalName == "complexType") { XmlSchemaComplexType xmlSchemaComplexType = XmlSchemaComplexType.Read(reader, h); if (xmlSchemaComplexType != null) { xmlSchemaRedefine.items.Add(xmlSchemaComplexType); } } else if (reader.LocalName == "group") { XmlSchemaGroup xmlSchemaGroup = XmlSchemaGroup.Read(reader, h); if (xmlSchemaGroup != null) { xmlSchemaRedefine.items.Add(xmlSchemaGroup); } } else if (reader.LocalName == "attributeGroup") { XmlSchemaAttributeGroup xmlSchemaAttributeGroup = XmlSchemaAttributeGroup.Read(reader, h); if (xmlSchemaAttributeGroup != null) { xmlSchemaRedefine.items.Add(xmlSchemaAttributeGroup); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaRedefine); }