//<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; }
internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaDocumentation xmlSchemaDocumentation = new XmlSchemaDocumentation(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "documentation") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaDocumentation.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaDocumentation.LineNumber = reader.LineNumber; xmlSchemaDocumentation.LinePosition = reader.LinePosition; xmlSchemaDocumentation.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "source") { xmlSchemaDocumentation.source = reader.Value; } else if (reader.Name == "xml:lang") { xmlSchemaDocumentation.language = reader.Value; } else { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for documentation", null); } } reader.MoveToElement(); if (reader.IsEmptyElement) { xmlSchemaDocumentation.Markup = new XmlNode[0]; return(xmlSchemaDocumentation); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.AppendChild(xmlDocument.ReadNode(reader)); XmlNode firstChild = xmlDocument.FirstChild; if (firstChild != null && firstChild.ChildNodes != null) { xmlSchemaDocumentation.Markup = new XmlNode[firstChild.ChildNodes.Count]; for (int i = 0; i < firstChild.ChildNodes.Count; i++) { xmlSchemaDocumentation.Markup[i] = firstChild.ChildNodes[i]; } } if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) { skip = true; } return(xmlSchemaDocumentation); }
//<maxExclusive // fixed = boolean : false // id = ID // value = anySimpleType // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</maxExclusive> internal static XmlSchemaMaxExclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaMaxExclusiveFacet maxex = new XmlSchemaMaxExclusiveFacet(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaMaxExclusiveFacet.Read, name="+reader.Name,null); reader.Skip(); return null; } maxex.LineNumber = reader.LineNumber; maxex.LinePosition = reader.LinePosition; maxex.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { maxex.Id = reader.Value; } else if(reader.Name == "fixed") { Exception innerex; maxex.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for fixed attribute",innerex); } else if(reader.Name == "value") { maxex.Value = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for "+xmlname,null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,maxex); } } reader.MoveToElement(); if(reader.IsEmptyElement) return maxex; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaMaxExclusiveFacet.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) maxex.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return maxex; }
//<simpleType // final = (#all | (list | union | restriction)) // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | list | union)) //</simpleType> internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleType stype = new XmlSchemaSimpleType(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } stype.LineNumber = reader.LineNumber; stype.LinePosition = reader.LinePosition; stype.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "final") { Exception innerex; stype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out innerex, "final", XmlSchemaUtil.FinalAllowed); if (innerex != null) { error(h, "some invalid values not a valid value for final", innerex); } } else if (reader.Name == "id") { stype.Id = reader.Value; } else if (reader.Name == "name") { stype.Name = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for simpleType", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, stype); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(stype); } // Content: (annotation?, (restriction | list | union)) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleType.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) { stype.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleTypeRestriction restriction = XmlSchemaSimpleTypeRestriction.Read(reader, h); if (restriction != null) { stype.content = restriction; } continue; } if (reader.LocalName == "list") { level = 3; XmlSchemaSimpleTypeList list = XmlSchemaSimpleTypeList.Read(reader, h); if (list != null) { stype.content = list; } continue; } if (reader.LocalName == "union") { level = 3; XmlSchemaSimpleTypeUnion union = XmlSchemaSimpleTypeUnion.Read(reader, h); if (union != null) { stype.content = union; } continue; } } reader.RaiseInvalidElementError(); } return(stype); }
internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroup xmlSchemaGroup = new XmlSchemaGroup(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaGroup.LineNumber = reader.LineNumber; xmlSchemaGroup.LinePosition = reader.LinePosition; xmlSchemaGroup.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaGroup.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaGroup.name = 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 group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaGroup); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaGroup); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaGroup.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaGroup.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "all") { num = 3; XmlSchemaAll xmlSchemaAll = XmlSchemaAll.Read(reader, h); if (xmlSchemaAll != null) { xmlSchemaGroup.Particle = xmlSchemaAll; } continue; } if (reader.LocalName == "choice") { num = 3; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaGroup.Particle = xmlSchemaChoice; } continue; } if (reader.LocalName == "sequence") { num = 3; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaGroup.Particle = xmlSchemaSequence; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaGroup); }
internal static XmlSchemaKeyref Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaKeyref xmlSchemaKeyref = new XmlSchemaKeyref(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "keyref") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaKeyref.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaKeyref.LineNumber = reader.LineNumber; xmlSchemaKeyref.LinePosition = reader.LinePosition; xmlSchemaKeyref.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaKeyref.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaKeyref.Name = reader.Value; } else if (reader.Name == "refer") { Exception ex; xmlSchemaKeyref.refer = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for refer attribute", ex); } } 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 keyref", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaKeyref); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaKeyref); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "keyref") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaKeyref.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaKeyref.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "selector") { num = 3; XmlSchemaXPath xmlSchemaXPath = XmlSchemaXPath.Read(reader, h, "selector"); if (xmlSchemaXPath != null) { xmlSchemaKeyref.Selector = xmlSchemaXPath; } } else if (num <= 3 && reader.LocalName == "field") { num = 3; if (xmlSchemaKeyref.Selector == null) { XmlSchemaObject.error(h, "selector must be defined before field declarations", null); } XmlSchemaXPath xmlSchemaXPath2 = XmlSchemaXPath.Read(reader, h, "field"); if (xmlSchemaXPath2 != null) { xmlSchemaKeyref.Fields.Add(xmlSchemaXPath2); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaKeyref); }
internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleType xmlSchemaSimpleType = new XmlSchemaSimpleType(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "simpleType") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaSimpleType.LineNumber = reader.LineNumber; xmlSchemaSimpleType.LinePosition = reader.LinePosition; xmlSchemaSimpleType.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "final") { Exception ex; xmlSchemaSimpleType.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out ex, "final", XmlSchemaUtil.FinalAllowed); if (ex != null) { XmlSchemaObject.error(h, "some invalid values not a valid value for final", ex); } } else if (reader.Name == "id") { xmlSchemaSimpleType.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaSimpleType.Name = 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 simpleType", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleType); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleType); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "simpleType") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleType.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleType.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "restriction") { num = 3; XmlSchemaSimpleTypeRestriction xmlSchemaSimpleTypeRestriction = XmlSchemaSimpleTypeRestriction.Read(reader, h); if (xmlSchemaSimpleTypeRestriction != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeRestriction; } continue; } if (reader.LocalName == "list") { num = 3; XmlSchemaSimpleTypeList xmlSchemaSimpleTypeList = XmlSchemaSimpleTypeList.Read(reader, h); if (xmlSchemaSimpleTypeList != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeList; } continue; } if (reader.LocalName == "union") { num = 3; XmlSchemaSimpleTypeUnion xmlSchemaSimpleTypeUnion = XmlSchemaSimpleTypeUnion.Read(reader, h); if (xmlSchemaSimpleTypeUnion != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeUnion; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleType); }
internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaNotation xmlSchemaNotation = new XmlSchemaNotation(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "notation") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaInclude.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaNotation.LineNumber = reader.LineNumber; xmlSchemaNotation.LinePosition = reader.LinePosition; xmlSchemaNotation.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaNotation.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaNotation.name = reader.Value; } else if (reader.Name == "public") { xmlSchemaNotation.pub = reader.Value; } else if (reader.Name == "system") { xmlSchemaNotation.system = 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 notation", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaNotation); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaNotation); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "notation") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaNotation.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaNotation.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaNotation); }
//<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; }
//<union // id = ID // memberTypes = List of QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType*)) //</union> internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeUnion union = new XmlSchemaSimpleTypeUnion(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name=" + reader.Name, null); reader.Skip(); return(null); } union.LineNumber = reader.LineNumber; union.LinePosition = reader.LinePosition; union.SourceUri = reader.BaseURI; //Read Attributes while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { union.Id = reader.Value; } else if (reader.Name == "memberTypes") { Exception innerEx; string[] names = XmlSchemaUtil.SplitList(reader.Value); union.memberTypes = new XmlQualifiedName[names.Length]; for (int i = 0; i < names.Length; i++) { union.memberTypes[i] = XmlSchemaUtil.ToQName(reader, names[i], out innerEx); if (innerEx != null) { error(h, "'" + names[i] + "' is not a valid memberType", innerEx); } } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for union", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, union); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(union); } // Content: annotation?, simpleType* int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleTypeUnion.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) { union.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "simpleType") { level = 2; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { union.baseTypes.Add(stype); } continue; } reader.RaiseInvalidElementError(); } return(union); }
//<simpleType // final = (#all | (list | union | restriction)) // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | list | union)) //</simpleType> internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleType stype = new XmlSchemaSimpleType(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null); reader.Skip(); return null; } stype.LineNumber = reader.LineNumber; stype.LinePosition = reader.LinePosition; stype.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "final") { Exception innerex; stype.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out innerex, "final", XmlSchemaUtil.FinalAllowed); if(innerex != null) error(h, "some invalid values not a valid value for final", innerex); } else if(reader.Name == "id") { stype.Id = reader.Value; } else if(reader.Name == "name") { stype.Name = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for simpleType",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,stype); } } reader.MoveToElement(); if(reader.IsEmptyElement) return stype; // Content: (annotation?, (restriction | list | union)) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleType.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) stype.Annotation = annotation; continue; } if(level <= 2) { if(reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleTypeRestriction restriction = XmlSchemaSimpleTypeRestriction.Read(reader,h); if(restriction != null) stype.content = restriction; continue; } if(reader.LocalName == "list") { level = 3; XmlSchemaSimpleTypeList list = XmlSchemaSimpleTypeList.Read(reader,h); if(list != null) stype.content = list; continue; } if(reader.LocalName == "union") { level = 3; XmlSchemaSimpleTypeUnion union = XmlSchemaSimpleTypeUnion.Read(reader,h); if(union != null) stype.content = union; continue; } } reader.RaiseInvalidElementError(); } return stype; }
//<union // id = ID // memberTypes = List of QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType*)) //</union> internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeUnion union = new XmlSchemaSimpleTypeUnion(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name="+reader.Name,null); reader.Skip(); return null; } union.LineNumber = reader.LineNumber; union.LinePosition = reader.LinePosition; union.SourceUri = reader.BaseURI; //Read Attributes while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { union.Id = reader.Value; } else if(reader.Name == "memberTypes") { Exception innerEx; string[] names = XmlSchemaUtil.SplitList(reader.Value); union.memberTypes = new XmlQualifiedName[names.Length]; for(int i=0;i<names.Length;i++) { union.memberTypes[i] = XmlSchemaUtil.ToQName(reader,names[i],out innerEx); if(innerEx != null) error(h,"'"+names[i] + "' is not a valid memberType",innerEx); } } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for union",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,union); } } reader.MoveToElement(); if(reader.IsEmptyElement) return union; // Content: annotation?, simpleType* int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleTypeUnion.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) union.Annotation = annotation; continue; } if(level <=2 && reader.LocalName == "simpleType") { level = 2; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h); if(stype != null) union.baseTypes.Add(stype); continue; } reader.RaiseInvalidElementError(); } return union; }
internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h, string name) { XmlSchemaXPath xmlSchemaXPath = new XmlSchemaXPath(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != name) { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaXPath.LineNumber = reader.LineNumber; xmlSchemaXPath.LinePosition = reader.LinePosition; xmlSchemaXPath.SourceUri = reader.BaseURI; XmlNamespaceManager namespaceManager = XmlSchemaUtil.GetParserContext(reader.Reader).NamespaceManager; if (namespaceManager != null) { xmlSchemaXPath.nsmgr = new XmlNamespaceManager(reader.NameTable); foreach (object obj in namespaceManager) { string text = obj as string; string text2 = text; if (text2 != null) { if (XmlSchemaXPath.< > f__switch$map3C == null) { XmlSchemaXPath.< > f__switch$map3C = new Dictionary <string, int>(2) { { "xml", 0 }, { "xmlns", 0 } }; } int num; if (XmlSchemaXPath.< > f__switch$map3C.TryGetValue(text2, out num)) { if (num == 0) { continue; } } } xmlSchemaXPath.nsmgr.AddNamespace(text, namespaceManager.LookupNamespace(text, false)); } } while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaXPath.Id = reader.Value; } else if (reader.Name == "xpath") { xmlSchemaXPath.xpath = 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 " + name, null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaXPath); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaXPath); } int num2 = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != name) { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaXPath.Read, name=" + reader.Name, null); } break; } if (num2 <= 1 && reader.LocalName == "annotation") { num2 = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaXPath.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaXPath); }
internal static XmlSchemaSequence Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "sequence") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaSequence.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaSequence.LineNumber = reader.LineNumber; xmlSchemaSequence.LinePosition = reader.LinePosition; xmlSchemaSequence.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaSequence.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { xmlSchemaSequence.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaSequence.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 sequence", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSequence); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSequence); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "sequence") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSequence.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSequence.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "element") { num = 2; XmlSchemaElement xmlSchemaElement = XmlSchemaElement.Read(reader, h); if (xmlSchemaElement != null) { xmlSchemaSequence.items.Add(xmlSchemaElement); } continue; } if (reader.LocalName == "group") { num = 2; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaSequence.items.Add(xmlSchemaGroupRef); } continue; } if (reader.LocalName == "choice") { num = 2; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaSequence.items.Add(xmlSchemaChoice); } continue; } if (reader.LocalName == "sequence") { num = 2; XmlSchemaSequence xmlSchemaSequence2 = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence2 != null) { xmlSchemaSequence.items.Add(xmlSchemaSequence2); } continue; } if (reader.LocalName == "any") { num = 2; XmlSchemaAny xmlSchemaAny = XmlSchemaAny.Read(reader, h); if (xmlSchemaAny != null) { xmlSchemaSequence.items.Add(xmlSchemaAny); } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaSequence); }
//<element // abstract = boolean : false // block = (#all | List of (extension | restriction | substitution)) // default = string // final = (#all | List of (extension | restriction)) // fixed = string // form = (qualified | unqualified) // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // name = NCName // nillable = boolean : false // ref = QName // substitutionGroup = QName // type = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*)) //</element> internal static XmlSchemaElement Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaElement element = new XmlSchemaElement(); Exception innerex; reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaElement.Read, name="+reader.Name,null); reader.Skip(); return null; } element.LineNumber = reader.LineNumber; element.LinePosition = reader.LinePosition; element.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "abstract") { element.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + " is invalid value for abstract",innerex); } else if(reader.Name == "block") { element.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block", XmlSchemaUtil.ElementBlockAllowed); if(innerex != null) error (h,"some invalid values for block attribute were found",innerex); } else if(reader.Name == "default") { element.defaultValue = reader.Value; } else if(reader.Name == "final") { element.Final = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "final", XmlSchemaUtil.FinalAllowed); if(innerex != null) error (h,"some invalid values for final attribute were found",innerex); } else if(reader.Name == "fixed") { element.fixedValue = reader.Value; } else if(reader.Name == "form") { element.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + " is an invalid value for form attribute",innerex); } else if(reader.Name == "id") { element.Id = reader.Value; } else if(reader.Name == "maxOccurs") { try { element.MaxOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for maxOccurs",e); } } else if(reader.Name == "minOccurs") { try { element.MinOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for minOccurs",e); } } else if(reader.Name == "name") { element.Name = reader.Value; } else if(reader.Name == "nillable") { element.IsNillable = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + "is not a valid value for nillable",innerex); } else if(reader.Name == "ref") { element.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for ref attribute",innerex); } else if(reader.Name == "substitutionGroup") { element.substitutionGroup = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for substitutionGroup attribute",innerex); } else if(reader.Name == "type") { element.SchemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for type attribute",innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for element",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,element); } } reader.MoveToElement(); if(reader.IsEmptyElement) return element; // Content: annotation?, // (simpleType | complexType)?, // (unique | key | keyref)* int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaElement.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) element.Annotation = annotation; continue; } if(level <= 2) { if(reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType simple = XmlSchemaSimpleType.Read(reader,h); if(simple != null) element.SchemaType = simple; continue; } if(reader.LocalName == "complexType") { level = 3; XmlSchemaComplexType complex = XmlSchemaComplexType.Read(reader,h); if(complex != null) { element.SchemaType = complex; } continue; } } if(level <= 3) { if(reader.LocalName == "unique") { level = 3; XmlSchemaUnique unique = XmlSchemaUnique.Read(reader,h); if(unique != null) element.constraints.Add(unique); continue; } else if(reader.LocalName == "key") { level = 3; XmlSchemaKey key = XmlSchemaKey.Read(reader,h); if(key != null) element.constraints.Add(key); continue; } else if(reader.LocalName == "keyref") { level = 3; XmlSchemaKeyref keyref = XmlSchemaKeyref.Read(reader,h); if(keyref != null) element.constraints.Add(keyref); continue; } } reader.RaiseInvalidElementError(); } return element; }
internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroupRef xmlSchemaGroupRef = new XmlSchemaGroupRef(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaGroupRef.LineNumber = reader.LineNumber; xmlSchemaGroupRef.LinePosition = reader.LinePosition; xmlSchemaGroupRef.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaGroupRef.Id = reader.Value; } else if (reader.Name == "ref") { Exception ex; xmlSchemaGroupRef.refName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for ref attribute", ex); } } else if (reader.Name == "maxOccurs") { try { xmlSchemaGroupRef.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaGroupRef.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 group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaGroupRef); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaGroupRef); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaGroupRef.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaGroupRef.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaGroupRef); }
//<list // id = ID // itemType = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType?)) //</list> internal static XmlSchemaSimpleTypeList Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaSimpleTypeList.Read, name="+reader.Name,null); reader.Skip(); return null; } list.LineNumber = reader.LineNumber; list.LinePosition = reader.LinePosition; list.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { list.Id = reader.Value; } else if(reader.Name == "itemType") { Exception innerex; list.ItemTypeName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for itemType attribute",innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for list",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,list); } } reader.MoveToElement(); if(reader.IsEmptyElement) return list; // Content: annotation?, simpleType? int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleTypeList.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) list.Annotation = annotation; continue; } if(level <= 2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h); if(stype != null) list.itemType = stype; continue; } reader.RaiseInvalidElementError(); } return list; }
// <group // id = ID // ref = QName // minOccurs = ? : 1 // maxOccurs = ? : 1> // Content: (annotation?) // </group> internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroupRef groupref = new XmlSchemaGroupRef(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null); reader.Skip(); return null; } groupref.LineNumber = reader.LineNumber; groupref.LinePosition = reader.LinePosition; groupref.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { groupref.Id = reader.Value; } else if(reader.Name == "ref") { Exception innerex; groupref.refName = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for ref attribute",innerex); } else if(reader.Name == "maxOccurs") { try { groupref.MaxOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for maxOccurs",e); } } else if(reader.Name == "minOccurs") { try { groupref.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 group",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,groupref); } } reader.MoveToElement(); if(reader.IsEmptyElement) return groupref; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaGroupRef.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) groupref.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return groupref; }
// <group // id = ID // ref = QName // minOccurs = ? : 1 // maxOccurs = ? : 1> // Content: (annotation?) // </group> internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroupRef groupref = new XmlSchemaGroupRef(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } groupref.LineNumber = reader.LineNumber; groupref.LinePosition = reader.LinePosition; groupref.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { groupref.Id = reader.Value; } else if (reader.Name == "ref") { Exception innerex; groupref.refName = XmlSchemaUtil.ReadQNameAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for ref attribute", innerex); } } else if (reader.Name == "maxOccurs") { try { groupref.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { groupref.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 group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, groupref); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(groupref); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaGroupRef.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) { groupref.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(groupref); }
//<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); }
//<list // id = ID // itemType = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType?)) //</list> internal static XmlSchemaSimpleTypeList Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeList list = new XmlSchemaSimpleTypeList(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaSimpleTypeList.Read, name=" + reader.Name, null); reader.Skip(); return(null); } list.LineNumber = reader.LineNumber; list.LinePosition = reader.LinePosition; list.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { list.Id = reader.Value; } else if (reader.Name == "itemType") { Exception innerex; list.ItemTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for itemType attribute", innerex); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for list", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, list); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(list); } // Content: annotation?, simpleType? int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleTypeList.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) { list.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { list.itemType = stype; } continue; } reader.RaiseInvalidElementError(); } return(list); }
//<sequence // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (element | group | choice | sequence | any)*) //</sequence> internal static XmlSchemaSequence Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSequence sequence = new XmlSchemaSequence(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaSequence.Read, name=" + reader.Name, null); reader.Skip(); return(null); } sequence.LineNumber = reader.LineNumber; sequence.LinePosition = reader.LinePosition; sequence.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { sequence.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { sequence.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { sequence.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 sequence", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, sequence); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(sequence); } // 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: XmlSchemaSequence.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) { sequence.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { sequence.items.Add(element); } continue; } if (reader.LocalName == "group") { level = 2; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader, h); if (group != null) { sequence.items.Add(group); } continue; } if (reader.LocalName == "choice") { level = 2; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader, h); if (choice != null) { sequence.items.Add(choice); } continue; } if (reader.LocalName == "sequence") { level = 2; XmlSchemaSequence seq = XmlSchemaSequence.Read(reader, h); if (seq != null) { sequence.items.Add(seq); } continue; } if (reader.LocalName == "any") { level = 2; XmlSchemaAny any = XmlSchemaAny.Read(reader, h); if (any != null) { sequence.items.Add(any); } continue; } } reader.RaiseInvalidElementError(); } return(sequence); }
//<sequence // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (element | group | choice | sequence | any)*) //</sequence> internal static XmlSchemaSequence Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSequence sequence = new XmlSchemaSequence(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaSequence.Read, name="+reader.Name,null); reader.Skip(); return null; } sequence.LineNumber = reader.LineNumber; sequence.LinePosition = reader.LinePosition; sequence.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { sequence.Id = reader.Value; } else if(reader.Name == "maxOccurs") { try { sequence.MaxOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for maxOccurs",e); } } else if(reader.Name == "minOccurs") { try { sequence.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 sequence",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,sequence); } } reader.MoveToElement(); if(reader.IsEmptyElement) return sequence; // 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: XmlSchemaSequence.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) sequence.Annotation = annotation; continue; } if(level <=2) { if(reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader,h); if(element != null) sequence.items.Add(element); continue; } if(reader.LocalName == "group") { level = 2; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h); if(group != null) sequence.items.Add(group); continue; } if(reader.LocalName == "choice") { level = 2; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h); if(choice != null) sequence.items.Add(choice); continue; } if(reader.LocalName == "sequence") { level = 2; XmlSchemaSequence seq = XmlSchemaSequence.Read(reader,h); if(seq != null) sequence.items.Add(seq); continue; } if(reader.LocalName == "any") { level = 2; XmlSchemaAny any = XmlSchemaAny.Read(reader,h); if(any != null) sequence.items.Add(any); continue; } } reader.RaiseInvalidElementError(); } return sequence; }
internal static XmlSchemaTotalDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaTotalDigitsFacet xmlSchemaTotalDigitsFacet = new XmlSchemaTotalDigitsFacet(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "totalDigits") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaTotalDigitsFacet.LineNumber = reader.LineNumber; xmlSchemaTotalDigitsFacet.LinePosition = reader.LinePosition; xmlSchemaTotalDigitsFacet.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaTotalDigitsFacet.Id = reader.Value; } else if (reader.Name == "fixed") { Exception ex; xmlSchemaTotalDigitsFacet.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for fixed attribute", ex); } } else if (reader.Name == "value") { xmlSchemaTotalDigitsFacet.Value = 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 totalDigits", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaTotalDigitsFacet); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaTotalDigitsFacet); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "totalDigits") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaTotalDigitsFacet.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaTotalDigitsFacet.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaTotalDigitsFacet); }
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); }
/* * internal new void error(ValidationEventHandler handle, string message) * { * errorCount++; * ValidationHandler.RaiseValidationError(handle, this, message); * } */ //<key // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (selector, field+)) //</key> internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaKey key = new XmlSchemaKey(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaKey.Read, name=" + reader.Name, null); reader.Skip(); return(null); } key.LineNumber = reader.LineNumber; key.LinePosition = reader.LinePosition; key.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { key.Id = reader.Value; } else if (reader.Name == "name") { key.Name = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for key", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, key); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(key); } // Content: annotation?, selector, field+ int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaKey.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) { key.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "selector") { level = 3; XmlSchemaXPath selector = XmlSchemaXPath.Read(reader, h, "selector"); if (selector != null) { key.Selector = selector; } continue; } if (level <= 3 && reader.LocalName == "field") { level = 3; if (key.Selector == null) { error(h, "selector must be defined before field declarations", null); } XmlSchemaXPath field = XmlSchemaXPath.Read(reader, h, "field"); if (field != null) { key.Fields.Add(field); } continue; } reader.RaiseInvalidElementError(); } return(key); }
//<complexContent // id = ID // mixed = boolean // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</complexContent> internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContent complex = new XmlSchemaComplexContent(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.Skip(); return(null); } complex.LineNumber = reader.LineNumber; complex.LinePosition = reader.LinePosition; complex.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { complex.Id = reader.Value; } else if (reader.Name == "mixed") { Exception innerex; complex.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is an invalid value for mixed", innerex); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for complexContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, complex); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(complex); } //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: XmlSchemaComplexContent.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) { complex.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaComplexContentRestriction restriction = XmlSchemaComplexContentRestriction.Read(reader, h); if (restriction != null) { complex.content = restriction; } continue; } if (reader.LocalName == "extension") { level = 3; XmlSchemaComplexContentExtension extension = XmlSchemaComplexContentExtension.Read(reader, h); if (extension != null) { complex.content = extension; } continue; } } reader.RaiseInvalidElementError(); } return(complex); }
//From the Errata //<group // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (all | choice | sequence)?) //</group> internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroup group = new XmlSchemaGroup(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaGroup.Read, name="+reader.Name,null); reader.Skip(); return null; } group.LineNumber = reader.LineNumber; group.LinePosition = reader.LinePosition; group.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { group.Id = reader.Value; } else if(reader.Name == "name") { group.name = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for group",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,group); } } reader.MoveToElement(); if(reader.IsEmptyElement) return group; // Content: (annotation?, (all | choice | sequence)?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaGroup.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) group.Annotation = annotation; continue; } if(level <= 2) { if(reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader,h); if(all != null) group.Particle = all; continue; } if(reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h); if(choice != null) group.Particle = choice; continue; } if(reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h); if(sequence != null) group.Particle = sequence; continue; } } reader.RaiseInvalidElementError(); } return group; }
//<restriction // base = QName // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))) //</restriction> internal static XmlSchemaComplexContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentRestriction restriction = new XmlSchemaComplexContentRestriction(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null); reader.Skip(); return null; } restriction.LineNumber = reader.LineNumber; restriction.LinePosition = reader.LinePosition; restriction.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "base") { Exception innerex; restriction.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") { restriction.Id = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for restriction",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction); } } reader.MoveToElement(); if(reader.IsEmptyElement) return restriction; //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: XmlSchemaComplexContentRestriction.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) restriction.Annotation = annotation; continue; } if(level <= 2) { if(reader.LocalName == "group") { level = 3; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h); if(group != null) restriction.particle = group; continue; } if(reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader,h); if(all != null) restriction.particle = all; continue; } if(reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h); if(choice != null) restriction.particle = choice; continue; } if(reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h); if(sequence != null) restriction.particle = sequence; continue; } } if(level <= 3) { if(reader.LocalName == "attribute") { level = 3; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) restriction.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 3; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) restriction.attributes.Add(attr); continue; } } if(level <= 4 && reader.LocalName == "anyAttribute") { level = 5; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) restriction.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return restriction; }
//<selector // id = ID // xpath = a subset of XPath expression, see below // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</selector> internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h, string name) { XmlSchemaXPath path = new XmlSchemaXPath(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != name) { error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.Skip(); return(null); } path.LineNumber = reader.LineNumber; path.LinePosition = reader.LinePosition; path.SourceUri = reader.BaseURI; XmlNamespaceManager currentMgr = XmlSchemaUtil.GetParserContext(reader.Reader).NamespaceManager; if (currentMgr != null) { path.nsmgr = new XmlNamespaceManager(reader.NameTable); IEnumerator e = currentMgr.GetEnumerator(); while (e.MoveNext()) { string prefix = e.Current as string; switch (prefix) { case "xml": case "xmlns": continue; default: path.nsmgr.AddNamespace(prefix, currentMgr.LookupNamespace(prefix, false)); break; } } } while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { path.Id = reader.Value; } else if (reader.Name == "xpath") { path.xpath = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for " + name, null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, path); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(path); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != name) { error(h, "Should not happen :2: XmlSchemaXPath.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) { path.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(path); }
//<pattern // id = ID // value = anySimpleType // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</pattern> internal static XmlSchemaPatternFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaPatternFacet pattern = new XmlSchemaPatternFacet(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaPatternFacet.Read, name="+reader.Name,null); reader.Skip(); return null; } pattern.LineNumber = reader.LineNumber; pattern.LinePosition = reader.LinePosition; pattern.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { pattern.Id = reader.Value; } else if(reader.Name == "value") { pattern.Value = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for "+xmlname,null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,pattern); } } reader.MoveToElement(); if(reader.IsEmptyElement) return pattern; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaPatternFacet.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) pattern.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return pattern; }
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); }
//<complexContent // id = ID // mixed = boolean // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</complexContent> internal static XmlSchemaComplexContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContent complex = new XmlSchemaComplexContent(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null); reader.Skip(); return null; } complex.LineNumber = reader.LineNumber; complex.LinePosition = reader.LinePosition; complex.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { complex.Id = reader.Value; } else if(reader.Name == "mixed") { Exception innerex; complex.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + " is an invalid value for mixed",innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for complexContent",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,complex); } } reader.MoveToElement(); if(reader.IsEmptyElement) return complex; //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: XmlSchemaComplexContent.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) complex.Annotation = annotation; continue; } if(level <=2) { if(reader.LocalName == "restriction") { level = 3; XmlSchemaComplexContentRestriction restriction = XmlSchemaComplexContentRestriction.Read(reader,h); if(restriction != null) complex.content = restriction; continue; } if(reader.LocalName == "extension") { level = 3; XmlSchemaComplexContentExtension extension = XmlSchemaComplexContentExtension.Read(reader,h); if(extension != null) complex.content = extension; continue; } } reader.RaiseInvalidElementError(); } return complex; }
//<extension //base = QName //id = ID //{any attributes with non-schema namespace . . .}> //Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) //</extension> internal static XmlSchemaSimpleContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentExtension extension = new XmlSchemaSimpleContentExtension(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAttributeGroup.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 in this context",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,extension); } } reader.MoveToElement(); if(reader.IsEmptyElement) return extension; //Content: 1.annotation?, 2.(attribute | attributeGroup)*, 3.anyAttribute? int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleContentExtension.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 == "attribute") { level = 2; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) extension.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 2; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) extension.attributes.Add(attr); continue; } } if(level <= 3 && reader.LocalName == "anyAttribute") { level = 4; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) extension.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return extension; }
//<restriction // base = QName // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits | fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*)) //</restriction> internal static XmlSchemaSimpleTypeRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaSimpleTypeRestriction.Read, name="+reader.Name,null); reader.Skip(); return null; } restriction.LineNumber = reader.LineNumber; restriction.LinePosition = reader.LinePosition; restriction.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { restriction.Id = reader.Value; } else if(reader.Name == "base") { Exception innerex; restriction.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.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for restriction",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,restriction); } } reader.MoveToElement(); if(reader.IsEmptyElement) return restriction; // Content: annotation?, simpleType?, (minExclusive |. .. | pattern)* int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleTypeRestriction.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) restriction.Annotation = annotation; continue; } if(level <= 2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h); if(stype != null) restriction.baseType = stype; continue; } if(level <= 3) { if(reader.LocalName == "minExclusive") { level = 3; XmlSchemaMinExclusiveFacet minex = XmlSchemaMinExclusiveFacet.Read(reader,h); if(minex != null) restriction.facets.Add(minex); continue; } else if(reader.LocalName == "minInclusive") { level = 3; XmlSchemaMinInclusiveFacet mini = XmlSchemaMinInclusiveFacet.Read(reader,h); if(mini != null) restriction.facets.Add(mini); continue; } else if(reader.LocalName == "maxExclusive") { level = 3; XmlSchemaMaxExclusiveFacet maxex = XmlSchemaMaxExclusiveFacet.Read(reader,h); if(maxex != null) restriction.facets.Add(maxex); continue; } else if(reader.LocalName == "maxInclusive") { level = 3; XmlSchemaMaxInclusiveFacet maxi = XmlSchemaMaxInclusiveFacet.Read(reader,h); if(maxi != null) restriction.facets.Add(maxi); continue; } else if(reader.LocalName == "totalDigits") { level = 3; XmlSchemaTotalDigitsFacet total = XmlSchemaTotalDigitsFacet.Read(reader,h); if(total != null) restriction.facets.Add(total); continue; } else if(reader.LocalName == "fractionDigits") { level = 3; XmlSchemaFractionDigitsFacet fraction = XmlSchemaFractionDigitsFacet.Read(reader,h); if(fraction != null) restriction.facets.Add(fraction); continue; } else if(reader.LocalName == "length") { level = 3; XmlSchemaLengthFacet length = XmlSchemaLengthFacet.Read(reader,h); if(length != null) restriction.facets.Add(length); continue; } else if(reader.LocalName == "minLength") { level = 3; XmlSchemaMinLengthFacet minlen = XmlSchemaMinLengthFacet.Read(reader,h); if(minlen != null) restriction.facets.Add(minlen); continue; } else if(reader.LocalName == "maxLength") { level = 3; XmlSchemaMaxLengthFacet maxlen = XmlSchemaMaxLengthFacet.Read(reader,h); if(maxlen != null) restriction.facets.Add(maxlen); continue; } else if(reader.LocalName == "enumeration") { level = 3; XmlSchemaEnumerationFacet enumeration = XmlSchemaEnumerationFacet.Read(reader,h); if(enumeration != null) restriction.facets.Add(enumeration); continue; } else if(reader.LocalName == "whiteSpace") { level = 3; XmlSchemaWhiteSpaceFacet ws = XmlSchemaWhiteSpaceFacet.Read(reader,h); if(ws != null) restriction.facets.Add(ws); continue; } else if(reader.LocalName == "pattern") { level = 3; XmlSchemaPatternFacet pattern = XmlSchemaPatternFacet.Read(reader,h); if(pattern != null) restriction.facets.Add(pattern); continue; } } reader.RaiseInvalidElementError(); } return restriction; }
//From the Errata //<group // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (all | choice | sequence)?) //</group> internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroup group = new XmlSchemaGroup(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } group.LineNumber = reader.LineNumber; group.LinePosition = reader.LinePosition; group.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { group.Id = reader.Value; } else if (reader.Name == "name") { group.name = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, group); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(group); } // Content: (annotation?, (all | choice | sequence)?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaGroup.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) { group.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "all") { level = 3; XmlSchemaAll all = XmlSchemaAll.Read(reader, h); if (all != null) { group.Particle = all; } continue; } if (reader.LocalName == "choice") { level = 3; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader, h); if (choice != null) { group.Particle = choice; } continue; } if (reader.LocalName == "sequence") { level = 3; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader, h); if (sequence != null) { group.Particle = sequence; } continue; } } reader.RaiseInvalidElementError(); } return(group); }
/* internal new void error(ValidationEventHandler handle, string message) { errorCount++; ValidationHandler.RaiseValidationError(handle, this, message); } */ //<key // id = ID // name = NCName // refer = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (selector, field+)) //</key> internal static XmlSchemaKeyref Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaKeyref keyref = new XmlSchemaKeyref(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaKeyref.Read, name="+reader.Name,null); reader.Skip(); return null; } keyref.LineNumber = reader.LineNumber; keyref.LinePosition = reader.LinePosition; keyref.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { keyref.Id = reader.Value; } else if(reader.Name == "name") { keyref.Name = reader.Value; } else if(reader.Name == "refer") { Exception innerex; keyref.refer = XmlSchemaUtil.ReadQNameAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for refer attribute",innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for keyref",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,keyref); } } reader.MoveToElement(); if(reader.IsEmptyElement) return keyref; // Content: annotation?, selector, field+ int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaKeyref.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) keyref.Annotation = annotation; continue; } if(level <= 2 && reader.LocalName == "selector") { level = 3; XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector"); if(selector != null) keyref.Selector = selector; continue; } if(level <= 3 && reader.LocalName == "field") { level = 3; if(keyref.Selector == null) error(h,"selector must be defined before field declarations",null); XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field"); if(field != null) keyref.Fields.Add(field); continue; } reader.RaiseInvalidElementError(); } return keyref; }
//<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); }
//<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); }
//<selector // id = ID // xpath = a subset of XPath expression, see below // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</selector> internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h,string name) { XmlSchemaXPath path = new XmlSchemaXPath(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != name) { error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null); reader.Skip(); return null; } path.LineNumber = reader.LineNumber; path.LinePosition = reader.LinePosition; path.SourceUri = reader.BaseURI; XmlNamespaceManager currentMgr = XmlSchemaUtil.GetParserContext (reader.Reader).NamespaceManager; if (currentMgr != null) { path.nsmgr = new XmlNamespaceManager (reader.NameTable); IEnumerator e = currentMgr.GetEnumerator (); while (e.MoveNext ()) { string prefix = e.Current as string; switch (prefix) { case "xml": case "xmlns": continue; default: path.nsmgr.AddNamespace (prefix, currentMgr.LookupNamespace (prefix, false)); break; } } } while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { path.Id = reader.Value; } else if(reader.Name == "xpath") { path.xpath = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for "+name,null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,path); } } reader.MoveToElement(); if(reader.IsEmptyElement) return path; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != name) error(h,"Should not happen :2: XmlSchemaXPath.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) path.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return path; }
//<notation // id = ID // name = NCName // public = anyURI // system = anyURI // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</notation> internal static XmlSchemaNotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaNotation notation = new XmlSchemaNotation(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaInclude.Read, name=" + reader.Name, null); reader.Skip(); return(null); } notation.LineNumber = reader.LineNumber; notation.LinePosition = reader.LinePosition; notation.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { notation.Id = reader.Value; } else if (reader.Name == "name") { notation.name = reader.Value; } else if (reader.Name == "public") { notation.pub = reader.Value; } else if (reader.Name == "system") { notation.system = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for notation", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, notation); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(notation); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaNotation.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) { notation.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(notation); }
//<fractionDigits // fixed = boolean : false // id = ID // value = nonNegativeInteger // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</fractionDigits> internal static XmlSchemaFractionDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaFractionDigitsFacet fraction = new XmlSchemaFractionDigitsFacet(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaFractionDigitsFacet.Read, name=" + reader.Name, null); reader.Skip(); return(null); } fraction.LineNumber = reader.LineNumber; fraction.LinePosition = reader.LinePosition; fraction.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { fraction.Id = reader.Value; } else if (reader.Name == "fixed") { Exception innerex; fraction.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for fixed attribute", innerex); } } else if (reader.Name == "value") { fraction.Value = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for " + xmlname, null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, fraction); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(fraction); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaFractionDigitsFacet.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) { fraction.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(fraction); }
internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeUnion xmlSchemaSimpleTypeUnion = new XmlSchemaSimpleTypeUnion(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "union") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaSimpleTypeUnion.LineNumber = reader.LineNumber; xmlSchemaSimpleTypeUnion.LinePosition = reader.LinePosition; xmlSchemaSimpleTypeUnion.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaSimpleTypeUnion.Id = reader.Value; } else if (reader.Name == "memberTypes") { string[] array = XmlSchemaUtil.SplitList(reader.Value); xmlSchemaSimpleTypeUnion.memberTypes = new XmlQualifiedName[array.Length]; for (int i = 0; i < array.Length; i++) { Exception ex; xmlSchemaSimpleTypeUnion.memberTypes[i] = XmlSchemaUtil.ToQName(reader, array[i], out ex); if (ex != null) { XmlSchemaObject.error(h, "'" + array[i] + "' is not a valid memberType", ex); } } } 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 union", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleTypeUnion); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleTypeUnion); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "union") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleTypeUnion.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleTypeUnion.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "simpleType") { num = 2; XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaSimpleTypeUnion.baseTypes.Add(xmlSchemaSimpleType); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleTypeUnion); }