/* * internal new void error(ValidationEventHandler handle, string message) * { * errorCount++; * ValidationHandler.RaiseValidationError(handle, this, message); * } */ //<unique // id = ID // name = NCName // {any attributes with non-schema namespace . . .}> // Content: (annotation?, (selector, field+)) //</unique> internal static XmlSchemaUnique Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaUnique unique = new XmlSchemaUnique(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaUnique.Read, name=" + reader.Name, null); reader.Skip(); return(null); } unique.LineNumber = reader.LineNumber; unique.LinePosition = reader.LinePosition; unique.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { unique.Id = reader.Value; } else if (reader.Name == "name") { unique.Name = reader.Value; } else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace) { error(h, reader.Name + " is not a valid attribute for unique", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, unique); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(unique); } // 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: XmlSchemaUnion.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) { unique.Annotation = annotation; } continue; } if (level <= 2 && reader.LocalName == "selector") { level = 3; XmlSchemaXPath selector = XmlSchemaXPath.Read(reader, h, "selector"); if (selector != null) { unique.Selector = selector; } continue; } if (level <= 3 && reader.LocalName == "field") { level = 3; if (unique.Selector == null) { error(h, "selector must be defined before field declarations", null); } XmlSchemaXPath field = XmlSchemaXPath.Read(reader, h, "field"); if (field != null) { unique.Fields.Add(field); } continue; } reader.RaiseInvalidElementError(); } return(unique); }
//<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); }
//<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); }
//<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); }
//<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); }
//<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); }
//<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); }
//<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); }
//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); }
//<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); }
//<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); }
//<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); }
// <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); }
//<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); }
private static void ReadContent(XmlSchema schema, XmlSchemaReader reader, ValidationEventHandler h) { reader.MoveToElement(); if (reader.LocalName != "schema" && reader.NamespaceURI != XmlSchema.Namespace && reader.NodeType != XmlNodeType.Element) { error(h, "UNREACHABLE CODE REACHED: Method: Schema.ReadContent, " + reader.LocalName + ", " + reader.NamespaceURI, null); } //(include | import | redefine | annotation)*, //((simpleType | complexType | group | attributeGroup | element | attribute | notation | annotation)* int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchema.Read, name=" + reader.Name, null); } break; } if (level <= 1) { if (reader.LocalName == "include") { XmlSchemaInclude include = XmlSchemaInclude.Read(reader, h); if (include != null) { schema.includes.Add(include); } continue; } if (reader.LocalName == "import") { XmlSchemaImport import = XmlSchemaImport.Read(reader, h); if (import != null) { schema.includes.Add(import); } continue; } if (reader.LocalName == "redefine") { XmlSchemaRedefine redefine = XmlSchemaRedefine.Read(reader, h); if (redefine != null) { schema.includes.Add(redefine); } continue; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { schema.items.Add(annotation); } continue; } } if (level <= 2) { level = 2; if (reader.LocalName == "simpleType") { XmlSchemaSimpleType stype = XmlSchemaSimpleType.Read(reader, h); if (stype != null) { schema.items.Add(stype); } continue; } if (reader.LocalName == "complexType") { XmlSchemaComplexType ctype = XmlSchemaComplexType.Read(reader, h); if (ctype != null) { schema.items.Add(ctype); } continue; } if (reader.LocalName == "group") { XmlSchemaGroup group = XmlSchemaGroup.Read(reader, h); if (group != null) { schema.items.Add(group); } continue; } if (reader.LocalName == "attributeGroup") { XmlSchemaAttributeGroup attributeGroup = XmlSchemaAttributeGroup.Read(reader, h); if (attributeGroup != null) { schema.items.Add(attributeGroup); } continue; } if (reader.LocalName == "element") { XmlSchemaElement element = XmlSchemaElement.Read(reader, h); if (element != null) { schema.items.Add(element); } continue; } if (reader.LocalName == "attribute") { XmlSchemaAttribute attr = XmlSchemaAttribute.Read(reader, h); if (attr != null) { schema.items.Add(attr); } continue; } if (reader.LocalName == "notation") { XmlSchemaNotation notation = XmlSchemaNotation.Read(reader, h); if (notation != null) { schema.items.Add(notation); } continue; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation annotation = XmlSchemaAnnotation.Read(reader, h); if (annotation != null) { schema.items.Add(annotation); } continue; } } reader.RaiseInvalidElementError(); } }
//<enumeration // id = ID // value = anySimpleType // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</enumeration> internal static XmlSchemaEnumerationFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaEnumerationFacet enumeration = new XmlSchemaEnumerationFacet(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaEnumerationFacet.Read, name=" + reader.Name, null); reader.Skip(); return(null); } enumeration.LineNumber = reader.LineNumber; enumeration.LinePosition = reader.LinePosition; enumeration.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { enumeration.Id = reader.Value; } else if (reader.Name == "value") { enumeration.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, enumeration); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(enumeration); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaEnumerationFacet.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) { enumeration.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(enumeration); }
//<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); }
//<maxInclusive // fixed = boolean : false // id = ID // value = anySimpleType // {any attributes with non-schema namespace . . .}> // Content: (annotation?) //</maxInclusive> internal static XmlSchemaMaxInclusiveFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaMaxInclusiveFacet maxi = new XmlSchemaMaxInclusiveFacet(); reader.MoveToElement(); if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname) { error(h, "Should not happen :1: XmlSchemaMaxInclusiveFacet.Read, name=" + reader.Name, null); reader.Skip(); return(null); } maxi.LineNumber = reader.LineNumber; maxi.LinePosition = reader.LinePosition; maxi.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { maxi.Id = reader.Value; } else if (reader.Name == "fixed") { Exception innerex; maxi.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") { maxi.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, maxi); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(maxi); } // Content: (annotation?) int level = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != xmlname) { error(h, "Should not happen :2: XmlSchemaMaxInclusiveFacet.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) { maxi.Annotation = annotation; } continue; } reader.RaiseInvalidElementError(); } return(maxi); }
//<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); }