//<documentation // source = anyURI // xml:lang = language> // Content: ({any})* //</documentation> internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaDocumentation doc = new XmlSchemaDocumentation(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "documentation") { error(h, "Should not happen :1: XmlSchemaDocumentation.Read, name=" + reader.Name, null); reader.Skip(); return(null); } doc.LineNumber = reader.LineNumber; doc.LinePosition = reader.LinePosition; doc.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "source") { doc.source = reader.Value; } else if (reader.Name == "xml:lang") { doc.language = reader.Value; } else { error(h, reader.Name + " is not a valid attribute for documentation", null); } } reader.MoveToElement(); if (reader.IsEmptyElement) { doc.Markup = new XmlNode[0]; return(doc); } //Content {any}* XmlDocument xmldoc = new XmlDocument(); xmldoc.AppendChild(xmldoc.ReadNode(reader)); XmlNode root = xmldoc.FirstChild; if (root != null && root.ChildNodes != null) { doc.Markup = new XmlNode[root.ChildNodes.Count]; for (int i = 0; i < root.ChildNodes.Count; i++) { doc.Markup[i] = root.ChildNodes[i]; } } if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) { skip = true; } return(doc); }
//<annotation // id = ID // {any attributes with non-schema namespace . . .}> // Content: (appinfo | documentation)* //</annotation> internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAnnotation.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } annotation.LineNumber = reader.LineNumber; annotation.LinePosition = reader.LinePosition; annotation.SourceUri = reader.BaseURI; //Read Attributes while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { annotation.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for annotation", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, annotation); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(annotation); } //Content: (appinfo | documentation)* bool skip = false; string expectedEnd = null; while (!reader.EOF) { if (skip) { skip = false; } else { reader.ReadNextElement(); } if (reader.NodeType == XmlNodeType.EndElement) { bool end = true; string expected = xmlname; if (expectedEnd != null) { expected = expectedEnd; expectedEnd = null; end = false; } if (reader.LocalName != expected) { error(h, "Should not happen :2: XmlSchemaAnnotation.Read, name=" + reader.Name + ",expected=" + expected, null); } if (end) { break; } else { continue; } } if (reader.LocalName == "appinfo") { XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader, h, out skip); if (appinfo != null) { annotation.items.Add(appinfo); } continue; } if (reader.LocalName == "documentation") { XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader, h, out skip); if (documentation != null) { annotation.items.Add(documentation); } continue; } reader.RaiseInvalidElementError(); } return(annotation); }