//<appinfo // source = anyURI> // Content: ({any})* //</appinfo> internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo") { error(h, "Should not happen :1: XmlSchemaAppInfo.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } appinfo.LineNumber = reader.LineNumber; appinfo.LinePosition = reader.LinePosition; appinfo.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "source") { appinfo.source = reader.Value; } else { error(h, reader.Name + " is not a valid attribute for appinfo", null); } } reader.MoveToElement(); if (reader.IsEmptyElement) { appinfo.Markup = new XmlNode [0]; return(appinfo); } //Content {any}* //FIXME: This is a pure Quick Hack; There must be a another method; XmlDocument xmldoc = new XmlDocument(); xmldoc.AppendChild(xmldoc.ReadNode(reader)); XmlNode root = xmldoc.FirstChild; if (root != null && root.ChildNodes != null) { appinfo.Markup = new XmlNode[root.ChildNodes.Count]; for (int i = 0; i < root.ChildNodes.Count; i++) { appinfo.Markup[i] = root.ChildNodes[i]; } } if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) { skip = true; } return(appinfo); }
//<appinfo // source = anyURI> // Content: ({any})* //</appinfo> internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaAppInfo appinfo = new XmlSchemaAppInfo(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "appinfo") { error(h,"Should not happen :1: XmlSchemaAppInfo.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } appinfo.LineNumber = reader.LineNumber; appinfo.LinePosition = reader.LinePosition; appinfo.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "source") { appinfo.source = reader.Value; } else { error(h,reader.Name + " is not a valid attribute for appinfo",null); } } reader.MoveToElement(); if(reader.IsEmptyElement) { appinfo.Markup = new XmlNode [0]; return appinfo; } //Content {any}* //FIXME: This is a pure Quick Hack; There must be a another method; XmlDocument xmldoc = new XmlDocument(); xmldoc.AppendChild(xmldoc.ReadNode(reader)); XmlNode root = xmldoc.FirstChild; if(root != null && root.ChildNodes != null) { appinfo.Markup = new XmlNode[root.ChildNodes.Count]; for(int i=0;i<root.ChildNodes.Count;i++) { appinfo.Markup[i] = root.ChildNodes[i]; } } if(reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) skip = true; return appinfo; }
internal static XmlSchemaAppInfo Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaAppInfo xmlSchemaAppInfo = new XmlSchemaAppInfo(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "appinfo") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAppInfo.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaAppInfo.LineNumber = reader.LineNumber; xmlSchemaAppInfo.LinePosition = reader.LinePosition; xmlSchemaAppInfo.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "source") { xmlSchemaAppInfo.source = reader.Value; } else { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for appinfo", null); } } reader.MoveToElement(); if (reader.IsEmptyElement) { xmlSchemaAppInfo.Markup = new XmlNode[0]; return(xmlSchemaAppInfo); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.AppendChild(xmlDocument.ReadNode(reader)); XmlNode firstChild = xmlDocument.FirstChild; if (firstChild != null && firstChild.ChildNodes != null) { xmlSchemaAppInfo.Markup = new XmlNode[firstChild.ChildNodes.Count]; for (int i = 0; i < firstChild.ChildNodes.Count; i++) { xmlSchemaAppInfo.Markup[i] = firstChild.ChildNodes[i]; } } if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) { skip = true; } return(xmlSchemaAppInfo); }
//<simpleContent // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</simpleContent> internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContent.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } simple.LineNumber = reader.LineNumber; simple.LinePosition = reader.LinePosition; simple.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { simple.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for simpleContent", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, simple); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(simple); } //Content: (annotation?, (restriction | extension)) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleContent.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { simple.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader, h); if (restriction != null) { simple.content = restriction; } continue; } if (reader.LocalName == "extension") { level = 3; XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader, h); if (extension != null) { simple.content = extension; } continue; } } reader.RaiseInvalidElementError(); } return(simple); }
//<attributeGroup // id = ID // ref = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</attributeGroup> internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAttributeGroupRef.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } attrgrp.LineNumber = reader.LineNumber; attrgrp.LinePosition = reader.LinePosition; attrgrp.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { attrgrp.Id = reader.Value; } else if (reader.Name == "ref") { Exception innerex; attrgrp.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.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for attributeGroup in this context", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, attrgrp); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(attrgrp); } int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaAttributeGroupRef.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) { attrgrp.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(attrgrp); }
internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction xmlSchemaSimpleContentRestriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "restriction") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaSimpleContentRestriction.LineNumber = reader.LineNumber; xmlSchemaSimpleContentRestriction.LinePosition = reader.LinePosition; xmlSchemaSimpleContentRestriction.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception ex; xmlSchemaSimpleContentRestriction.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") { xmlSchemaSimpleContentRestriction.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 restriction", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleContentRestriction); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleContentRestriction); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "restriction") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleContentRestriction.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleContentRestriction.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "simpleType") { num = 3; XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaSimpleContentRestriction.baseType = xmlSchemaSimpleType; } } else { if (num <= 3) { if (reader.LocalName == "minExclusive") { num = 3; XmlSchemaMinExclusiveFacet xmlSchemaMinExclusiveFacet = XmlSchemaMinExclusiveFacet.Read(reader, h); if (xmlSchemaMinExclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinExclusiveFacet); } continue; } if (reader.LocalName == "minInclusive") { num = 3; XmlSchemaMinInclusiveFacet xmlSchemaMinInclusiveFacet = XmlSchemaMinInclusiveFacet.Read(reader, h); if (xmlSchemaMinInclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinInclusiveFacet); } continue; } if (reader.LocalName == "maxExclusive") { num = 3; XmlSchemaMaxExclusiveFacet xmlSchemaMaxExclusiveFacet = XmlSchemaMaxExclusiveFacet.Read(reader, h); if (xmlSchemaMaxExclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxExclusiveFacet); } continue; } if (reader.LocalName == "maxInclusive") { num = 3; XmlSchemaMaxInclusiveFacet xmlSchemaMaxInclusiveFacet = XmlSchemaMaxInclusiveFacet.Read(reader, h); if (xmlSchemaMaxInclusiveFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxInclusiveFacet); } continue; } if (reader.LocalName == "totalDigits") { num = 3; XmlSchemaTotalDigitsFacet xmlSchemaTotalDigitsFacet = XmlSchemaTotalDigitsFacet.Read(reader, h); if (xmlSchemaTotalDigitsFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaTotalDigitsFacet); } continue; } if (reader.LocalName == "fractionDigits") { num = 3; XmlSchemaFractionDigitsFacet xmlSchemaFractionDigitsFacet = XmlSchemaFractionDigitsFacet.Read(reader, h); if (xmlSchemaFractionDigitsFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaFractionDigitsFacet); } continue; } if (reader.LocalName == "length") { num = 3; XmlSchemaLengthFacet xmlSchemaLengthFacet = XmlSchemaLengthFacet.Read(reader, h); if (xmlSchemaLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaLengthFacet); } continue; } if (reader.LocalName == "minLength") { num = 3; XmlSchemaMinLengthFacet xmlSchemaMinLengthFacet = XmlSchemaMinLengthFacet.Read(reader, h); if (xmlSchemaMinLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMinLengthFacet); } continue; } if (reader.LocalName == "maxLength") { num = 3; XmlSchemaMaxLengthFacet xmlSchemaMaxLengthFacet = XmlSchemaMaxLengthFacet.Read(reader, h); if (xmlSchemaMaxLengthFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaMaxLengthFacet); } continue; } if (reader.LocalName == "enumeration") { num = 3; XmlSchemaEnumerationFacet xmlSchemaEnumerationFacet = XmlSchemaEnumerationFacet.Read(reader, h); if (xmlSchemaEnumerationFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaEnumerationFacet); } continue; } if (reader.LocalName == "whiteSpace") { num = 3; XmlSchemaWhiteSpaceFacet xmlSchemaWhiteSpaceFacet = XmlSchemaWhiteSpaceFacet.Read(reader, h); if (xmlSchemaWhiteSpaceFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaWhiteSpaceFacet); } continue; } if (reader.LocalName == "pattern") { num = 3; XmlSchemaPatternFacet xmlSchemaPatternFacet = XmlSchemaPatternFacet.Read(reader, h); if (xmlSchemaPatternFacet != null) { xmlSchemaSimpleContentRestriction.facets.Add(xmlSchemaPatternFacet); } continue; } } if (num <= 4) { if (reader.LocalName == "attribute") { num = 4; XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h); if (xmlSchemaAttribute != null) { xmlSchemaSimpleContentRestriction.Attributes.Add(xmlSchemaAttribute); } continue; } if (reader.LocalName == "attributeGroup") { num = 4; XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h); if (xmlSchemaAttributeGroupRef != null) { xmlSchemaSimpleContentRestriction.attributes.Add(xmlSchemaAttributeGroupRef); } continue; } } if (num <= 5 && reader.LocalName == "anyAttribute") { num = 6; XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h); if (xmlSchemaAnyAttribute != null) { xmlSchemaSimpleContentRestriction.AnyAttribute = xmlSchemaAnyAttribute; } } else { reader.RaiseInvalidElementError(); } } } return(xmlSchemaSimpleContentRestriction); }
//<attribute // default = string // fixed = string // form = (qualified | unqualified) // id = ID // name = NCName // ref = QName // type = QName // use = (optional | prohibited | required) : optional // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType?)) //</attribute> internal static XmlSchemaAttribute Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttribute attribute = new XmlSchemaAttribute(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAttribute.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } attribute.LineNumber = reader.LineNumber; attribute.LinePosition = reader.LinePosition; attribute.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "default") { attribute.defaultValue = reader.Value; } else if (reader.Name == "fixed") { attribute.fixedValue = reader.Value; } else if (reader.Name == "form") { Exception innerex; attribute.form = XmlSchemaUtil.ReadFormAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for form attribute", innerex); } } else if (reader.Name == "id") { attribute.Id = reader.Value; } else if (reader.Name == "name") { attribute.name = reader.Value; } else if (reader.Name == "ref") { Exception innerex; attribute.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 == "type") { Exception innerex; attribute.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.Name == "use") { Exception innerex; attribute.use = XmlSchemaUtil.ReadUseAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for use attribute", innerex); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for attribute", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, attribute); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(attribute); } // Content: (annotation?, (simpleType?)) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaAttribute.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) { attribute.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { attribute.schemaType = stype; } continue; } reader.RaiseInvalidElementError(); } return(attribute); }
internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaInclude xmlSchemaInclude = new XmlSchemaInclude(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "include") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaInclude.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaInclude.LineNumber = reader.LineNumber; xmlSchemaInclude.LinePosition = reader.LinePosition; xmlSchemaInclude.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaInclude.Id = reader.Value; } else if (reader.Name == "schemaLocation") { xmlSchemaInclude.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 include", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaInclude); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaInclude); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "include") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaInclude.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaInclude.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaInclude); }
//<simpleContent // id = ID // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (restriction | extension)) //</simpleContent> internal static XmlSchemaSimpleContent Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContent simple = new XmlSchemaSimpleContent(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContent.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } simple.LineNumber = reader.LineNumber; simple.LinePosition = reader.LinePosition; simple.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { simple.Id = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for simpleContent",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,simple); } } reader.MoveToElement(); if(reader.IsEmptyElement) return simple; //Content: (annotation?, (restriction | extension)) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleContent.Read, name="+reader.Name,null); break; } if(level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h); if(annotation != null) simple.Annotation = annotation; continue; } if(level <=2) { if(reader.LocalName == "restriction") { level = 3; XmlSchemaSimpleContentRestriction restriction = XmlSchemaSimpleContentRestriction.Read(reader,h); if(restriction != null) simple.content = restriction; continue; } if(reader.LocalName == "extension") { level = 3; XmlSchemaSimpleContentExtension extension = XmlSchemaSimpleContentExtension.Read(reader,h); if(extension != null) simple.content = extension; continue; } } reader.RaiseInvalidElementError(); } return simple; }
//<include // id = ID // schemaLocation = anyURI // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</include> internal static XmlSchemaInclude Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaInclude include = new XmlSchemaInclude(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaInclude.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } include.LineNumber = reader.LineNumber; include.LinePosition = reader.LinePosition; include.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { include.Id = reader.Value; } else if(reader.Name == "schemaLocation") { include.SchemaLocation = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for include",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,include); } } reader.MoveToElement(); if(reader.IsEmptyElement) return include; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaInclude.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) include.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return include; }
//<attribute // default = string // fixed = string // form = (qualified | unqualified) // id = ID // name = NCName // ref = QName // type = QName // use = (optional | prohibited | required) : optional // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleType?)) //</attribute> internal static XmlSchemaAttribute Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttribute attribute = new XmlSchemaAttribute(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAttribute.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } attribute.LineNumber = reader.LineNumber; attribute.LinePosition = reader.LinePosition; attribute.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "default") { attribute.defaultValue = reader.Value; } else if(reader.Name == "fixed") { attribute.fixedValue = reader.Value; } else if(reader.Name == "form") { Exception innerex; attribute.form = XmlSchemaUtil.ReadFormAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for form attribute", innerex); } else if(reader.Name == "id") { attribute.Id = reader.Value; } else if(reader.Name == "name") { attribute.name = reader.Value; } else if(reader.Name == "ref") { Exception innerex; attribute.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 == "type") { Exception innerex; attribute.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.Name == "use") { Exception innerex; attribute.use = XmlSchemaUtil.ReadUseAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for use attribute", innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for attribute",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,attribute); } } reader.MoveToElement(); if(reader.IsEmptyElement) return attribute; // Content: (annotation?, (simpleType?)) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaAttribute.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) attribute.Annotation = annotation; continue; } if(level <=2 && reader.LocalName == "simpleType") { level = 3; XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader,h); if(stype != null) attribute.schemaType = stype; continue; } reader.RaiseInvalidElementError(); } return attribute; }
//<all // id = ID // maxOccurs = 1 : 1 // minOccurs = (0 | 1) : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, element*) //</all> internal static XmlSchemaAll Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAll all = new XmlSchemaAll(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAll.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } all.LineNumber = reader.LineNumber; all.LinePosition = reader.LinePosition; all.SourceUri = reader.BaseURI; //Read Attributes while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { all.Id = reader.Value; } else if(reader.Name == "maxOccurs") { try { all.MaxOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for maxOccurs",e); } } else if(reader.Name == "minOccurs") { try { all.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 all",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,all); } } reader.MoveToElement(); if(reader.IsEmptyElement) return all; //Content: (annotation?, element*) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaAll.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) all.Annotation = annotation; continue; } if(level <=2 && reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader,h); if(element != null) all.items.Add(element); continue; } reader.RaiseInvalidElementError(); } return all; }
internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAnnotation xmlSchemaAnnotation = new XmlSchemaAnnotation(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "annotation") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAnnotation.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaAnnotation.LineNumber = reader.LineNumber; xmlSchemaAnnotation.LinePosition = reader.LinePosition; xmlSchemaAnnotation.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaAnnotation.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 annotation", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAnnotation); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaAnnotation); } bool flag = false; string text = null; while (!reader.EOF) { if (flag) { flag = false; } else { reader.ReadNextElement(); } if (reader.NodeType == XmlNodeType.EndElement) { bool flag2 = true; string text2 = "annotation"; if (text != null) { text2 = text; text = null; flag2 = false; } if (reader.LocalName != text2) { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAnnotation.Read, name=" + reader.Name + ",expected=" + text2, null); } if (flag2) { break; } } else if (reader.LocalName == "appinfo") { XmlSchemaAppInfo xmlSchemaAppInfo = XmlSchemaAppInfo.Read(reader, h, out flag); if (xmlSchemaAppInfo != null) { xmlSchemaAnnotation.items.Add(xmlSchemaAppInfo); } } else if (reader.LocalName == "documentation") { XmlSchemaDocumentation xmlSchemaDocumentation = XmlSchemaDocumentation.Read(reader, h, out flag); if (xmlSchemaDocumentation != null) { xmlSchemaAnnotation.items.Add(xmlSchemaDocumentation); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaAnnotation); }
//<anyAttribute // id = ID // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any // processContents = (lax | skip | strict) : strict // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</anyAttribute> internal static XmlSchemaAnyAttribute Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAnyAttribute any = new XmlSchemaAnyAttribute(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAnyAttribute.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } any.LineNumber = reader.LineNumber; any.LinePosition = reader.LinePosition; any.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { any.Id = reader.Value; } else if(reader.Name == "namespace") { any.nameSpace = reader.Value; } else if(reader.Name == "processContents") { Exception innerex; any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader,out innerex); if(innerex != null) error(h, reader.Value + " is not a valid value for processContents",innerex); } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for anyAttribute",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,any); } } reader.MoveToElement(); if(reader.IsEmptyElement) return any; // Content: (annotation?) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaAnyAttribute.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) any.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return any; }
//<annotation // id = ID // {any attributes with non-schema namespace . . .}> // Content: (appinfo | documentation)* //</annotation> internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAnnotation.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } annotation.LineNumber = reader.LineNumber; annotation.LinePosition = reader.LinePosition; annotation.SourceUri = reader.BaseURI; //Read Attributes while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { annotation.Id = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for annotation",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,annotation); } } reader.MoveToElement(); if(reader.IsEmptyElement) return annotation; //Content: (appinfo | documentation)* bool skip = false; string expectedEnd = null; while(!reader.EOF) { if(skip) skip=false; else reader.ReadNextElement(); if(reader.NodeType == XmlNodeType.EndElement) { bool end = true; string expected = xmlname; if(expectedEnd != null) { expected = expectedEnd; expectedEnd = null; end = false; } if(reader.LocalName != expected) error(h,"Should not happen :2: XmlSchemaAnnotation.Read, name="+reader.Name+",expected="+expected,null); if (end) break; else continue; } if(reader.LocalName == "appinfo") { XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader,h,out skip); if(appinfo != null) annotation.items.Add(appinfo); continue; } if(reader.LocalName == "documentation") { XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader,h, out skip); if(documentation != null) annotation.items.Add(documentation); continue; } reader.RaiseInvalidElementError(); } return annotation; }
//<choice // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (element | group | choice | sequence | any)*) //</choice> internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaChoice choice = new XmlSchemaChoice(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaChoice.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } choice.LineNumber = reader.LineNumber; choice.LinePosition = reader.LinePosition; choice.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { choice.Id = reader.Value; } else if(reader.Name == "maxOccurs") { try { choice.MaxOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for maxOccurs",e); } } else if(reader.Name == "minOccurs") { try { choice.MinOccursString = reader.Value; } catch(Exception e) { error(h,reader.Value + " is an invalid value for minOccurs",e); } } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for choice",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,choice); } } reader.MoveToElement(); if(reader.IsEmptyElement) return choice; // Content: (annotation?, (element | group | choice | sequence | any)*) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaChoice.Read, name="+reader.Name,null); break; } if(level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader,h); if(annotation != null) choice.Annotation = annotation; continue; } if(level <=2) { if(reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader,h); if(element != null) choice.items.Add(element); continue; } if(reader.LocalName == "group") { level = 2; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h); if(group != null) choice.items.Add(group); continue; } if(reader.LocalName == "choice") { level = 2; XmlSchemaChoice ch = XmlSchemaChoice.Read(reader,h); if(ch != null) choice.items.Add(ch); continue; } if(reader.LocalName == "sequence") { level = 2; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h); if(sequence != null) choice.items.Add(sequence); continue; } if(reader.LocalName == "any") { level = 2; XmlSchemaAny any = XmlSchemaAny.Read(reader,h); if(any != null) choice.items.Add(any); continue; } } reader.RaiseInvalidElementError(); } return choice; }
//<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)*)?, ((attribute | attributeGroup)*, anyAttribute?)) //</restriction> internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.SkipToEnd(); 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.simpleType?, // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*, // 4.(attribute | attributeGroup)*, // 5.anyAttribute? int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaSimpleContentRestriction.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; } } if (level <= 4) { if (reader.LocalName == "attribute") { level = 4; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { restriction.Attributes.Add(attr); } continue; } if (reader.LocalName == "attributeGroup") { level = 4; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader, h); if (attr != null) { restriction.attributes.Add(attr); } continue; } } if (level <= 5 && reader.LocalName == "anyAttribute") { level = 6; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader, h); if (anyattr != null) { restriction.AnyAttribute = anyattr; } continue; } reader.RaiseInvalidElementError(); } return(restriction); }
//<all // id = ID // maxOccurs = 1 : 1 // minOccurs = (0 | 1) : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, element*) //</all> internal static XmlSchemaAll Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAll all = new XmlSchemaAll(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAll.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } all.LineNumber = reader.LineNumber; all.LinePosition = reader.LinePosition; all.SourceUri = reader.BaseURI; //Read Attributes while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { all.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { all.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { all.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 all", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, all); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(all); } //Content: (annotation?, element*) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaAll.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) { all.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { all.items.Add(element); } continue; } reader.RaiseInvalidElementError(); } return(all); }
//<attributeGroup // id = ID // ref = QName // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</attributeGroup> internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttributeGroupRef attrgrp = new XmlSchemaAttributeGroupRef(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAttributeGroupRef.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } attrgrp.LineNumber = reader.LineNumber; attrgrp.LinePosition = reader.LinePosition; attrgrp.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { attrgrp.Id = reader.Value; } else if(reader.Name == "ref") { Exception innerex; attrgrp.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.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp); } } reader.MoveToElement(); if(reader.IsEmptyElement) return attrgrp; int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaAttributeGroupRef.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) attrgrp.Annotation = annotation; continue; } reader.RaiseInvalidElementError(); } return attrgrp; }
//<attributeGroup // id = ID // name = NCName // ref = QName // Not present in this class. // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) //</attributeGroup> internal static XmlSchemaAttributeGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttributeGroup attrgrp = new XmlSchemaAttributeGroup(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaAttributeGroup.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } attrgrp.LineNumber = reader.LineNumber; attrgrp.LinePosition = reader.LinePosition; attrgrp.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "id") { attrgrp.Id = reader.Value; } else if(reader.Name == "name") { attrgrp.name = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for attributeGroup in this context",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,attrgrp); } } reader.MoveToElement(); if(reader.IsEmptyElement) return attrgrp; //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: XmlSchemaAttributeGroup.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) attrgrp.Annotation = annotation; continue; } if(level <= 2) { if(reader.LocalName == "attribute") { level = 2; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) attrgrp.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 2; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) attrgrp.attributes.Add(attr); continue; } } if(level <= 3 && reader.LocalName == "anyAttribute") { level = 4; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) attrgrp.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return attrgrp; }
//<any // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) ) : ##any // processContents = (lax | skip | strict) : strict // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</any> internal static XmlSchemaAny Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAny any = new XmlSchemaAny(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAny.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } any.LineNumber = reader.LineNumber; any.LinePosition = reader.LinePosition; any.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { any.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { any.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { any.MinOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for minOccurs", e); } } else if (reader.Name == "namespace") { any.nameSpace = reader.Value; } else if (reader.Name == "processContents") { Exception innerex; any.processing = XmlSchemaUtil.ReadProcessingAttribute(reader, out innerex); if (innerex != null) { error(h, reader.Value + " is not a valid value for processContents", innerex); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for any", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, any); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(any); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaAny.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) { any.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(any); }
//<choice // id = ID // maxOccurs = (nonNegativeInteger | unbounded) : 1 // minOccurs = nonNegativeInteger : 1 // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (element | group | choice | sequence | any)*) //</choice> internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaChoice choice = new XmlSchemaChoice(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaChoice.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } choice.LineNumber = reader.LineNumber; choice.LinePosition = reader.LinePosition; choice.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { choice.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { choice.MaxOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for maxOccurs", e); } } else if (reader.Name == "minOccurs") { try { choice.MinOccursString = reader.Value; } catch (Exception e) { error(h, reader.Value + " is an invalid value for minOccurs", e); } } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for choice", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, choice); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(choice); } // Content: (annotation?, (element | group | choice | sequence | any)*) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaChoice.Read, name=" + reader.Name, null); } break; } if (level <= 1 && reader.LocalName == "annotation") { level = 2; //Only one annotation XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { choice.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "element") { level = 2; XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { choice.items.Add(element); } continue; } if (reader.LocalName == "group") { level = 2; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader, h); if (group != null) { choice.items.Add(group); } continue; } if (reader.LocalName == "choice") { level = 2; XmlSchemaChoice ch = XmlSchemaChoice.Read(reader, h); if (ch != null) { choice.items.Add(ch); } continue; } if (reader.LocalName == "sequence") { level = 2; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader, h); if (sequence != null) { choice.items.Add(sequence); } continue; } if (reader.LocalName == "any") { level = 2; XmlSchemaAny any = XmlSchemaAny.Read(reader, h); if (any != null) { choice.items.Add(any); } continue; } } reader.RaiseInvalidElementError(); } return(choice); }
//<import // id = ID // namespace = anyURI // schemaLocation = anyURI // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</import> internal static XmlSchemaImport Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaImport import = new XmlSchemaImport(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != "import") { error(h, "Should not happen :1: XmlSchemaImport.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } import.LineNumber = reader.LineNumber; import.LinePosition = reader.LinePosition; import.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { import.Id = reader.Value; } else if (reader.Name == "namespace") { import.nameSpace = reader.Value; } else if (reader.Name == "schemaLocation") { import.SchemaLocation = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for import", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, import); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(import); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaImport.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) { import.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(import); }
//<complexType // abstract = boolean : false // block = (#all | List of (extension | restriction)) // final = (#all | List of (extension | restriction)) // id = ID // mixed = boolean : false // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (simpleContent | complexContent | ((group | all | choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?)))) //</complexType> internal static XmlSchemaComplexType Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexType ctype = new XmlSchemaComplexType(); reader.MoveToElement(); Exception innerex; if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexType.Read, name="+reader.Name,null); reader.SkipToEnd(); return null; } ctype.LineNumber = reader.LineNumber; ctype.LinePosition = reader.LinePosition; ctype.SourceUri = reader.BaseURI; while(reader.MoveToNextAttribute()) { if(reader.Name == "abstract") { ctype.IsAbstract = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + " is invalid value for abstract",innerex); } else if(reader.Name == "block") { ctype.block = XmlSchemaUtil.ReadDerivationAttribute(reader,out innerex, "block", XmlSchemaUtil.ComplexTypeBlockAllowed); if(innerex != null) error (h,"some invalid values for block attribute were found",innerex); } else if(reader.Name == "final") { ctype.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 == "id") { ctype.Id = reader.Value; } else if(reader.Name == "mixed") { ctype.isMixed = XmlSchemaUtil.ReadBoolAttribute(reader,out innerex); if(innerex != null) error(h,reader.Value + " is invalid value for mixed",innerex); } else if(reader.Name == "name") { ctype.Name = reader.Value; } else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h,reader.Name + " is not a valid attribute for complexType",null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader,ctype); } } reader.MoveToElement(); if(reader.IsEmptyElement) return ctype; //Content: 1. annotation?, // 2. simpleContent | 2. complexContent | // (3.(group | all | choice | sequence)?, (4.(attribute | attributeGroup)*, 5.anyAttribute?))) int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaComplexType.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) ctype.Annotation = annotation; continue; } if(level <=2) { if(reader.LocalName == "simpleContent") { level = 6; XmlSchemaSimpleContent simple = XmlSchemaSimpleContent.Read(reader,h); if(simple != null) ctype.ContentModel = simple; continue; } if(reader.LocalName == "complexContent") { level = 6; XmlSchemaComplexContent complex = XmlSchemaComplexContent.Read(reader,h); if(complex != null) ctype.contentModel = complex; continue; } } if(level <= 3) { if(reader.LocalName == "group") { level = 4; XmlSchemaGroupRef group = XmlSchemaGroupRef.Read(reader,h); if(group != null) ctype.particle = group; continue; } if(reader.LocalName == "all") { level = 4; XmlSchemaAll all = XmlSchemaAll.Read(reader,h); if(all != null) ctype.particle = all; continue; } if(reader.LocalName == "choice") { level = 4; XmlSchemaChoice choice = XmlSchemaChoice.Read(reader,h); if(choice != null) ctype.particle = choice; continue; } if(reader.LocalName == "sequence") { level = 4; XmlSchemaSequence sequence = XmlSchemaSequence.Read(reader,h); if(sequence != null) ctype.particle = sequence; continue; } } if(level <= 4) { if(reader.LocalName == "attribute") { level = 4; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) ctype.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 4; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) ctype.attributes.Add(attr); continue; } } if(level <= 5 && reader.LocalName == "anyAttribute") { level = 6; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) ctype.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return ctype; }
//<annotation // id = ID // {any attributes with non-schema namespace . . .}> // Content: (appinfo | documentation)* //</annotation> internal static XmlSchemaAnnotation Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAnnotation annotation = new XmlSchemaAnnotation(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAnnotation.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } annotation.LineNumber = reader.LineNumber; annotation.LinePosition = reader.LinePosition; annotation.SourceUri = reader.BaseURI; //Read Attributes while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { annotation.Id = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for annotation", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, annotation); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(annotation); } //Content: (appinfo | documentation)* bool skip = false; string expectedEnd = null; while (!reader.EOF) { if (skip) { skip = false; } else { reader.ReadNextElement(); } if (reader.NodeType == XmlNodeType.EndElement) { bool end = true; string expected = xmlname; if (expectedEnd != null) { expected = expectedEnd; expectedEnd = null; end = false; } if (reader.LocalName != expected) { error(h, "Should not happen :2: XmlSchemaAnnotation.Read, name=" + reader.Name + ",expected=" + expected, null); } if (end) { break; } else { continue; } } if (reader.LocalName == "appinfo") { XmlSchemaAppInfo appinfo = XmlSchemaAppInfo.Read(reader, h, out skip); if (appinfo != null) { annotation.items.Add(appinfo); } continue; } if (reader.LocalName == "documentation") { XmlSchemaDocumentation documentation = XmlSchemaDocumentation.Read(reader, h, out skip); if (documentation != null) { annotation.items.Add(documentation); } continue; } reader.RaiseInvalidElementError(); } return(annotation); }
internal static XmlSchemaAll Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAll xmlSchemaAll = new XmlSchemaAll(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "all") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAll.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaAll.LineNumber = reader.LineNumber; xmlSchemaAll.LinePosition = reader.LinePosition; xmlSchemaAll.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaAll.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { xmlSchemaAll.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaAll.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 all", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAll); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaAll); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "all") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAll.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaAll.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "element") { num = 2; XmlSchemaElement xmlSchemaElement = XmlSchemaElement.Read(reader, h); if (xmlSchemaElement != null) { xmlSchemaAll.items.Add(xmlSchemaElement); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaAll); }
internal static XmlSchemaAttribute Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttribute xmlSchemaAttribute = new XmlSchemaAttribute(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "attribute") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAttribute.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaAttribute.LineNumber = reader.LineNumber; xmlSchemaAttribute.LinePosition = reader.LinePosition; xmlSchemaAttribute.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "default") { xmlSchemaAttribute.defaultValue = reader.Value; } else if (reader.Name == "fixed") { xmlSchemaAttribute.fixedValue = reader.Value; } else if (reader.Name == "form") { Exception ex; xmlSchemaAttribute.form = XmlSchemaUtil.ReadFormAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for form attribute", ex); } } else if (reader.Name == "id") { xmlSchemaAttribute.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaAttribute.name = reader.Value; } else if (reader.Name == "ref") { Exception ex2; xmlSchemaAttribute.refName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex2); if (ex2 != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for ref attribute", ex2); } } else if (reader.Name == "type") { Exception ex3; xmlSchemaAttribute.schemaTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex3); if (ex3 != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for type attribute", ex3); } } else if (reader.Name == "use") { Exception ex4; xmlSchemaAttribute.use = XmlSchemaUtil.ReadUseAttribute(reader, out ex4); if (ex4 != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for use attribute", ex4); } } 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 attribute", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAttribute); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaAttribute); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "attribute") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAttribute.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaAttribute.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "simpleType") { num = 3; XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaAttribute.schemaType = xmlSchemaSimpleType; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaAttribute); }
internal static XmlSchemaAttributeGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = new XmlSchemaAttributeGroupRef(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "attributeGroup") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaAttributeGroupRef.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaAttributeGroupRef.LineNumber = reader.LineNumber; xmlSchemaAttributeGroupRef.LinePosition = reader.LinePosition; xmlSchemaAttributeGroupRef.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaAttributeGroupRef.Id = reader.Value; } else if (reader.Name == "ref") { Exception ex; xmlSchemaAttributeGroupRef.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.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 attributeGroup in this context", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaAttributeGroupRef); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaAttributeGroupRef); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "attributeGroup") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaAttributeGroupRef.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaAttributeGroupRef.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaAttributeGroupRef); }
//<attributeGroup // id = ID // name = NCName // ref = QName // Not present in this class. // {any attributes with non-schema namespace . . .}> // Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?)) //</attributeGroup> internal static XmlSchemaAttributeGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaAttributeGroup attrgrp = new XmlSchemaAttributeGroup(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaAttributeGroup.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } attrgrp.LineNumber = reader.LineNumber; attrgrp.LinePosition = reader.LinePosition; attrgrp.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { attrgrp.Id = reader.Value; } else if (reader.Name == "name") { attrgrp.name = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for attributeGroup in this context", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, attrgrp); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(attrgrp); } //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: XmlSchemaAttributeGroup.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) { attrgrp.Annotation = annotation; } continue; } if (level <= 2) { if (reader.LocalName == "attribute") { level = 2; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { attrgrp.Attributes.Add(attr); } continue; } if (reader.LocalName == "attributeGroup") { level = 2; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader, h); if (attr != null) { attrgrp.attributes.Add(attr); } continue; } } if (level <= 3 && reader.LocalName == "anyAttribute") { level = 4; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader, h); if (anyattr != null) { attrgrp.AnyAttribute = anyattr; } continue; } reader.RaiseInvalidElementError(); } return(attrgrp); }
//<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)*)?, ((attribute | attributeGroup)*, anyAttribute?)) //</restriction> internal static XmlSchemaSimpleContentRestriction Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleContentRestriction restriction = new XmlSchemaSimpleContentRestriction(); reader.MoveToElement(); if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h,"Should not happen :1: XmlSchemaComplexContentRestriction.Read, name="+reader.Name,null); reader.SkipToEnd(); 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.simpleType?, // 3.(minExclusive |...| enumeration | whiteSpace | pattern)*, // 4.(attribute | attributeGroup)*, // 5.anyAttribute? int level = 1; while(reader.ReadNextElement()) { if(reader.NodeType == XmlNodeType.EndElement) { if(reader.LocalName != xmlname) error(h,"Should not happen :2: XmlSchemaSimpleContentRestriction.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; } } if(level <= 4) { if(reader.LocalName == "attribute") { level = 4; XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader,h); if(attr != null) restriction.Attributes.Add(attr); continue; } if(reader.LocalName == "attributeGroup") { level = 4; XmlSchemaAttributeGroupRef attr = XmlSchemaAttributeGroupRef.Read(reader,h); if(attr != null) restriction.attributes.Add(attr); continue; } } if(level <= 5 && reader.LocalName == "anyAttribute") { level = 6; XmlSchemaAnyAttribute anyattr = XmlSchemaAnyAttribute.Read(reader,h); if(anyattr != null) restriction.AnyAttribute = anyattr; continue; } reader.RaiseInvalidElementError(); } return restriction; }