public static void AddToTable (XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains (qname)) { // FIXME: This logic unexpectedly allows // one redefining item and two or more redefining items. // FIXME: redefining item is not simple replacement, // but much more complex stuff. if (obj.isRedefineChild) { // take precedence. if (obj.redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else obj.redefinedObject = table [qname]; table.Set (qname, obj); } else if (table [qname].isRedefineChild) { if (table [qname].redefinedObject != null) obj.error (h, String.Format ("Named item {0} was already contained in the schema object table.", qname)); else table [qname].redefinedObject = obj; return; // never add to the table. } else if (StrictMsCompliant) { table.Set (qname, obj); } else obj.error (h, String.Format ("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } else table.Set (qname, obj); }
public static void AddToTable(XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains(qname)) { // FIXME: This logic unexpectedly allows // one redefining item and two or more redefining items. // FIXME: redefining item is not simple replacement, // but much more complex stuff. if (obj.isRedefineChild) // take precedence. { if (obj.redefinedObject != null) { obj.error(h, String.Format("Named item {0} was already contained in the schema object table.", qname)); } else { obj.redefinedObject = table [qname]; } table.Set(qname, obj); } else if (table [qname].isRedefineChild) { if (table [qname].redefinedObject != null) { obj.error(h, String.Format("Named item {0} was already contained in the schema object table.", qname)); } else { table [qname].redefinedObject = obj; } return; // never add to the table. } else if (StrictMsCompliant) { table.Set(qname, obj); } else { obj.error(h, String.Format("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } } else { table.Set(qname, obj); } }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (base.IsValidated(schema.ValidationId)) { return(this.errorCount); } if (this.Particle != null) { this.Particle.parentIsGroupDefinition = true; try { this.Particle.CheckRecursion(0, h, schema); } catch (XmlSchemaException ex) { XmlSchemaObject.error(h, ex.Message, ex); this.isCircularDefinition = true; return(this.errorCount); } this.errorCount += this.Particle.Validate(h, schema); this.Particle.ValidateUniqueParticleAttribution(new XmlSchemaObjectTable(), new ArrayList(), h, schema); this.Particle.ValidateUniqueTypeAttribution(new XmlSchemaObjectTable(), h, schema); } this.ValidationId = schema.ValidationId; return(this.errorCount); }
public static void AddToTable(XmlSchemaObjectTable table, XmlSchemaObject obj, XmlQualifiedName qname, ValidationEventHandler h) { if (table.Contains(qname)) { if (obj.isRedefineChild) { if (obj.redefinedObject != null) { obj.error(h, string.Format("Named item {0} was already contained in the schema object table.", qname)); } else { obj.redefinedObject = table[qname]; } table.Set(qname, obj); } else { if (table[qname].isRedefineChild) { if (table[qname].redefinedObject != null) { obj.error(h, string.Format("Named item {0} was already contained in the schema object table.", qname)); } else { table[qname].redefinedObject = obj; } return; } if (XmlSchemaUtil.StrictMsCompliant) { table.Set(qname, obj); } else { obj.error(h, string.Format("Named item {0} was already contained in the schema object table. {1}", qname, "Consider setting MONO_STRICT_MS_COMPLIANT to 'yes' to mimic MS implementation.")); } } } else { table.Set(qname, obj); } }
public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h) { if (id == null) { return; } if (!XmlSchemaUtil.CheckNCName(id)) { xso.error(h, id + " is not a valid id attribute"); } else if (idCollection.ContainsKey(id)) { xso.error(h, "Duplicate id attribute " + id); } else { idCollection.Add(id, xso); } }
internal static XmlSchemaDocumentation Read(XmlSchemaReader reader, ValidationEventHandler h, out bool skip) { skip = false; XmlSchemaDocumentation xmlSchemaDocumentation = new XmlSchemaDocumentation(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "documentation") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaDocumentation.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaDocumentation.LineNumber = reader.LineNumber; xmlSchemaDocumentation.LinePosition = reader.LinePosition; xmlSchemaDocumentation.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "source") { xmlSchemaDocumentation.source = reader.Value; } else if (reader.Name == "xml:lang") { xmlSchemaDocumentation.language = reader.Value; } else { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for documentation", null); } } reader.MoveToElement(); if (reader.IsEmptyElement) { xmlSchemaDocumentation.Markup = new XmlNode[0]; return(xmlSchemaDocumentation); } XmlDocument xmlDocument = new XmlDocument(); xmlDocument.AppendChild(xmlDocument.ReadNode(reader)); XmlNode firstChild = xmlDocument.FirstChild; if (firstChild != null && firstChild.ChildNodes != null) { xmlSchemaDocumentation.Markup = new XmlNode[firstChild.ChildNodes.Count]; for (int i = 0; i < firstChild.ChildNodes.Count; i++) { xmlSchemaDocumentation.Markup[i] = firstChild.ChildNodes[i]; } } if (reader.NodeType == XmlNodeType.Element || reader.NodeType == XmlNodeType.EndElement) { skip = true; } return(xmlSchemaDocumentation); }
public void RaiseInvalidElementError() { string errstr = "Element " + FullName + " is invalid in this context.\n"; if (hasLineInfo) { errstr += "The error occured on (" + ((IXmlLineInfo)reader).LineNumber + "," + ((IXmlLineInfo)reader).LinePosition + ")"; } XmlSchemaObject.error(handler, errstr, null); SkipToEnd(); }
public static void CompileID(string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID // 1. ID must be a NCName // 2. ID must be unique in the schema if (id == null) { return; } if (!CheckNCName(id)) { xso.error(h, id + " is not a valid id attribute"); } else if (idCollection.ContainsKey(id)) { xso.error(h, "Duplicate id attribute " + id); } else { idCollection.Add(id, xso); } }
public void RaiseInvalidElementError() { string text = "Element " + this.FullName + " is invalid in this context.\n"; if (this.hasLineInfo) { string text2 = text; text = string.Concat(new object[] { text2, "The error occured on (", ((IXmlLineInfo)this.reader).LineNumber, ",", ((IXmlLineInfo)this.reader).LinePosition, ")" }); } XmlSchemaObject.error(this.handler, text, null); this.SkipToEnd(); }
internal static void error(ValidationEventHandler handle, string message, Exception innerException) { XmlSchemaObject.error(handle, message, innerException, null, null); }
internal static XmlSchemaTotalDigitsFacet Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaTotalDigitsFacet xmlSchemaTotalDigitsFacet = new XmlSchemaTotalDigitsFacet(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "totalDigits") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaTotalDigitsFacet.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaTotalDigitsFacet.LineNumber = reader.LineNumber; xmlSchemaTotalDigitsFacet.LinePosition = reader.LinePosition; xmlSchemaTotalDigitsFacet.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaTotalDigitsFacet.Id = reader.Value; } else if (reader.Name == "fixed") { Exception ex; xmlSchemaTotalDigitsFacet.IsFixed = XmlSchemaUtil.ReadBoolAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for fixed attribute", ex); } } else if (reader.Name == "value") { xmlSchemaTotalDigitsFacet.Value = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for totalDigits", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaTotalDigitsFacet); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaTotalDigitsFacet); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "totalDigits") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaTotalDigitsFacet.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaTotalDigitsFacet.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaTotalDigitsFacet); }
internal void error(ValidationEventHandler handle, string message) { this.errorCount++; XmlSchemaObject.error(handle, message, null, this, null); }
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 XmlSchemaComplexContentExtension Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaComplexContentExtension xmlSchemaComplexContentExtension = new XmlSchemaComplexContentExtension(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "extension") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaComplexContentExtension.LineNumber = reader.LineNumber; xmlSchemaComplexContentExtension.LinePosition = reader.LinePosition; xmlSchemaComplexContentExtension.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "base") { Exception ex; xmlSchemaComplexContentExtension.baseTypeName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for base attribute", ex); } } else if (reader.Name == "id") { xmlSchemaComplexContentExtension.Id = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for extension", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaComplexContentExtension); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaComplexContentExtension); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "extension") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaComplexContentExtension.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaComplexContentExtension.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "group") { num = 3; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaGroupRef; } continue; } if (reader.LocalName == "all") { num = 3; XmlSchemaAll xmlSchemaAll = XmlSchemaAll.Read(reader, h); if (xmlSchemaAll != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaAll; } continue; } if (reader.LocalName == "choice") { num = 3; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaChoice; } continue; } if (reader.LocalName == "sequence") { num = 3; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaComplexContentExtension.particle = xmlSchemaSequence; } continue; } } if (num <= 3) { if (reader.LocalName == "attribute") { num = 3; XmlSchemaAttribute xmlSchemaAttribute = XmlSchemaAttribute.Read(reader, h); if (xmlSchemaAttribute != null) { xmlSchemaComplexContentExtension.Attributes.Add(xmlSchemaAttribute); } continue; } if (reader.LocalName == "attributeGroup") { num = 3; XmlSchemaAttributeGroupRef xmlSchemaAttributeGroupRef = XmlSchemaAttributeGroupRef.Read(reader, h); if (xmlSchemaAttributeGroupRef != null) { xmlSchemaComplexContentExtension.attributes.Add(xmlSchemaAttributeGroupRef); } continue; } } if (num <= 4 && reader.LocalName == "anyAttribute") { num = 5; XmlSchemaAnyAttribute xmlSchemaAnyAttribute = XmlSchemaAnyAttribute.Read(reader, h); if (xmlSchemaAnyAttribute != null) { xmlSchemaComplexContentExtension.AnyAttribute = xmlSchemaAnyAttribute; } } else { reader.RaiseInvalidElementError(); } } } return(xmlSchemaComplexContentExtension); }
internal static XmlSchemaKeyref Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaKeyref xmlSchemaKeyref = new XmlSchemaKeyref(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "keyref") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaKeyref.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaKeyref.LineNumber = reader.LineNumber; xmlSchemaKeyref.LinePosition = reader.LinePosition; xmlSchemaKeyref.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaKeyref.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaKeyref.Name = reader.Value; } else if (reader.Name == "refer") { Exception ex; xmlSchemaKeyref.refer = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for refer attribute", ex); } } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for keyref", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaKeyref); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaKeyref); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "keyref") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaKeyref.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaKeyref.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "selector") { num = 3; XmlSchemaXPath xmlSchemaXPath = XmlSchemaXPath.Read(reader, h, "selector"); if (xmlSchemaXPath != null) { xmlSchemaKeyref.Selector = xmlSchemaXPath; } } else if (num <= 3 && reader.LocalName == "field") { num = 3; if (xmlSchemaKeyref.Selector == null) { XmlSchemaObject.error(h, "selector must be defined before field declarations", null); } XmlSchemaXPath xmlSchemaXPath2 = XmlSchemaXPath.Read(reader, h, "field"); if (xmlSchemaXPath2 != null) { xmlSchemaKeyref.Fields.Add(xmlSchemaXPath2); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaKeyref); }
internal static XmlSchemaGroup Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroup xmlSchemaGroup = new XmlSchemaGroup(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaGroup.LineNumber = reader.LineNumber; xmlSchemaGroup.LinePosition = reader.LinePosition; xmlSchemaGroup.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaGroup.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaGroup.name = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaGroup); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaGroup); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaGroup.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaGroup.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "all") { num = 3; XmlSchemaAll xmlSchemaAll = XmlSchemaAll.Read(reader, h); if (xmlSchemaAll != null) { xmlSchemaGroup.Particle = xmlSchemaAll; } continue; } if (reader.LocalName == "choice") { num = 3; XmlSchemaChoice xmlSchemaChoice = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice != null) { xmlSchemaGroup.Particle = xmlSchemaChoice; } continue; } if (reader.LocalName == "sequence") { num = 3; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaGroup.Particle = xmlSchemaSequence; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaGroup); }
internal static XmlSchemaChoice Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaChoice xmlSchemaChoice = new XmlSchemaChoice(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "choice") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaChoice.Read, name=" + reader.Name, null); reader.SkipToEnd(); return(null); } xmlSchemaChoice.LineNumber = reader.LineNumber; xmlSchemaChoice.LinePosition = reader.LinePosition; xmlSchemaChoice.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaChoice.Id = reader.Value; } else if (reader.Name == "maxOccurs") { try { xmlSchemaChoice.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaChoice.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 choice", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaChoice); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaChoice); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "choice") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaChoice.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaChoice.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "element") { num = 2; XmlSchemaElement xmlSchemaElement = XmlSchemaElement.Read(reader, h); if (xmlSchemaElement != null) { xmlSchemaChoice.items.Add(xmlSchemaElement); } continue; } if (reader.LocalName == "group") { num = 2; XmlSchemaGroupRef xmlSchemaGroupRef = XmlSchemaGroupRef.Read(reader, h); if (xmlSchemaGroupRef != null) { xmlSchemaChoice.items.Add(xmlSchemaGroupRef); } continue; } if (reader.LocalName == "choice") { num = 2; XmlSchemaChoice xmlSchemaChoice2 = XmlSchemaChoice.Read(reader, h); if (xmlSchemaChoice2 != null) { xmlSchemaChoice.items.Add(xmlSchemaChoice2); } continue; } if (reader.LocalName == "sequence") { num = 2; XmlSchemaSequence xmlSchemaSequence = XmlSchemaSequence.Read(reader, h); if (xmlSchemaSequence != null) { xmlSchemaChoice.items.Add(xmlSchemaSequence); } continue; } if (reader.LocalName == "any") { num = 2; XmlSchemaAny xmlSchemaAny = XmlSchemaAny.Read(reader, h); if (xmlSchemaAny != null) { xmlSchemaChoice.items.Add(xmlSchemaAny); } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaChoice); }
internal static XmlSchemaXPath Read(XmlSchemaReader reader, ValidationEventHandler h, string name) { XmlSchemaXPath xmlSchemaXPath = new XmlSchemaXPath(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != name) { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaComplexContentRestriction.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaXPath.LineNumber = reader.LineNumber; xmlSchemaXPath.LinePosition = reader.LinePosition; xmlSchemaXPath.SourceUri = reader.BaseURI; XmlNamespaceManager namespaceManager = XmlSchemaUtil.GetParserContext(reader.Reader).NamespaceManager; if (namespaceManager != null) { xmlSchemaXPath.nsmgr = new XmlNamespaceManager(reader.NameTable); foreach (object obj in namespaceManager) { string text = obj as string; string text2 = text; if (text2 != null) { if (XmlSchemaXPath.< > f__switch$map3C == null) { XmlSchemaXPath.< > f__switch$map3C = new Dictionary <string, int>(2) { { "xml", 0 }, { "xmlns", 0 } }; } int num; if (XmlSchemaXPath.< > f__switch$map3C.TryGetValue(text2, out num)) { if (num == 0) { continue; } } } xmlSchemaXPath.nsmgr.AddNamespace(text, namespaceManager.LookupNamespace(text, false)); } } while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaXPath.Id = reader.Value; } else if (reader.Name == "xpath") { xmlSchemaXPath.xpath = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for " + name, null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaXPath); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaXPath); } int num2 = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != name) { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaXPath.Read, name=" + reader.Name, null); } break; } if (num2 <= 1 && reader.LocalName == "annotation") { num2 = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaXPath.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaXPath); }
internal static XmlSchemaSimpleType Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleType xmlSchemaSimpleType = new XmlSchemaSimpleType(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "simpleType") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaSimpleType.LineNumber = reader.LineNumber; xmlSchemaSimpleType.LinePosition = reader.LinePosition; xmlSchemaSimpleType.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "final") { Exception ex; xmlSchemaSimpleType.Final = XmlSchemaUtil.ReadDerivationAttribute(reader, out ex, "final", XmlSchemaUtil.FinalAllowed); if (ex != null) { XmlSchemaObject.error(h, "some invalid values not a valid value for final", ex); } } else if (reader.Name == "id") { xmlSchemaSimpleType.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaSimpleType.Name = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for simpleType", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleType); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleType); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "simpleType") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleType.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleType.Annotation = xmlSchemaAnnotation; } } else { if (num <= 2) { if (reader.LocalName == "restriction") { num = 3; XmlSchemaSimpleTypeRestriction xmlSchemaSimpleTypeRestriction = XmlSchemaSimpleTypeRestriction.Read(reader, h); if (xmlSchemaSimpleTypeRestriction != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeRestriction; } continue; } if (reader.LocalName == "list") { num = 3; XmlSchemaSimpleTypeList xmlSchemaSimpleTypeList = XmlSchemaSimpleTypeList.Read(reader, h); if (xmlSchemaSimpleTypeList != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeList; } continue; } if (reader.LocalName == "union") { num = 3; XmlSchemaSimpleTypeUnion xmlSchemaSimpleTypeUnion = XmlSchemaSimpleTypeUnion.Read(reader, h); if (xmlSchemaSimpleTypeUnion != null) { xmlSchemaSimpleType.content = xmlSchemaSimpleTypeUnion; } continue; } } reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleType); }
internal static 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); }
internal static XmlSchemaRedefine Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaRedefine xmlSchemaRedefine = new XmlSchemaRedefine(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "redefine") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaRedefine.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaRedefine.LineNumber = reader.LineNumber; xmlSchemaRedefine.LinePosition = reader.LinePosition; xmlSchemaRedefine.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaRedefine.Id = reader.Value; } else if (reader.Name == "schemaLocation") { xmlSchemaRedefine.SchemaLocation = reader.Value; } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for redefine", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaRedefine); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaRedefine); } while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "redefine") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaRedefine.Read, name=" + reader.Name, null); } break; } if (reader.LocalName == "annotation") { XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaRedefine.items.Add(xmlSchemaAnnotation); } } else if (reader.LocalName == "simpleType") { XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaRedefine.items.Add(xmlSchemaSimpleType); } } else if (reader.LocalName == "complexType") { XmlSchemaComplexType xmlSchemaComplexType = XmlSchemaComplexType.Read(reader, h); if (xmlSchemaComplexType != null) { xmlSchemaRedefine.items.Add(xmlSchemaComplexType); } } else if (reader.LocalName == "group") { XmlSchemaGroup xmlSchemaGroup = XmlSchemaGroup.Read(reader, h); if (xmlSchemaGroup != null) { xmlSchemaRedefine.items.Add(xmlSchemaGroup); } } else if (reader.LocalName == "attributeGroup") { XmlSchemaAttributeGroup xmlSchemaAttributeGroup = XmlSchemaAttributeGroup.Read(reader, h); if (xmlSchemaAttributeGroup != null) { xmlSchemaRedefine.items.Add(xmlSchemaAttributeGroup); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaRedefine); }
internal 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); }
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); }
internal override int Validate(ValidationEventHandler h, XmlSchema schema) { if (base.IsValidated(schema.ValidationId)) { return(this.errorCount); } if (this.SchemaType != null) { this.SchemaType.Validate(h, schema); this.attributeType = this.SchemaType; } else if (this.SchemaTypeName != null && this.SchemaTypeName != XmlQualifiedName.Empty) { XmlSchemaType xmlSchemaType = schema.FindSchemaType(this.SchemaTypeName); if (xmlSchemaType is XmlSchemaComplexType) { base.error(h, "An attribute can't have complexType Content"); } else if (xmlSchemaType != null) { this.errorCount += xmlSchemaType.Validate(h, schema); this.attributeType = xmlSchemaType; } else if (this.SchemaTypeName == XmlSchemaComplexType.AnyTypeName) { this.attributeType = XmlSchemaComplexType.AnyType; } else if (XmlSchemaUtil.IsBuiltInDatatypeName(this.SchemaTypeName)) { this.attributeType = XmlSchemaDatatype.FromName(this.SchemaTypeName); if (this.attributeType == null) { base.error(h, "Invalid xml schema namespace datatype was specified."); } } else if (!schema.IsNamespaceAbsent(this.SchemaTypeName.Namespace)) { base.error(h, "Referenced schema type " + this.SchemaTypeName + " was not found in the corresponding schema."); } } if (this.RefName != null && this.RefName != XmlQualifiedName.Empty) { this.referencedAttribute = schema.FindAttribute(this.RefName); if (this.referencedAttribute != null) { this.errorCount += this.referencedAttribute.Validate(h, schema); } else if (!schema.IsNamespaceAbsent(this.RefName.Namespace)) { base.error(h, "Referenced attribute " + this.RefName + " was not found in the corresponding schema."); } } if (this.attributeType == null) { this.attributeType = XmlSchemaSimpleType.AnySimpleType; } if (this.defaultValue != null || this.fixedValue != null) { XmlSchemaDatatype xmlSchemaDatatype = this.attributeType as XmlSchemaDatatype; if (xmlSchemaDatatype == null) { xmlSchemaDatatype = ((XmlSchemaSimpleType)this.attributeType).Datatype; } if (xmlSchemaDatatype.TokenizedType == XmlTokenizedType.QName) { base.error(h, "By the defection of the W3C XML Schema specification, it is impossible to supply QName default or fixed values."); } else { try { if (this.defaultValue != null) { this.validatedDefaultValue = xmlSchemaDatatype.Normalize(this.defaultValue); xmlSchemaDatatype.ParseValue(this.validatedDefaultValue, null, null); } } catch (Exception innerException) { XmlSchemaObject.error(h, "The Attribute's default value is invalid with its type definition.", innerException); } try { if (this.fixedValue != null) { this.validatedFixedValue = xmlSchemaDatatype.Normalize(this.fixedValue); this.validatedFixedTypedValue = xmlSchemaDatatype.ParseValue(this.validatedFixedValue, null, null); } } catch (Exception innerException2) { XmlSchemaObject.error(h, "The Attribute's fixed value is invalid with its type definition.", innerException2); } } } if (this.Use == XmlSchemaUse.None) { this.validatedUse = XmlSchemaUse.Optional; } else { this.validatedUse = this.Use; } if (this.attributeType != null) { this.attributeSchemaType = (this.attributeType as XmlSchemaSimpleType); if (this.attributeType == XmlSchemaSimpleType.AnySimpleType) { this.attributeSchemaType = XmlSchemaSimpleType.XsAnySimpleType; } if (this.attributeSchemaType == null) { this.attributeSchemaType = XmlSchemaType.GetBuiltInSimpleType(this.SchemaTypeName); } } this.ValidationId = schema.ValidationId; return(this.errorCount); }
public static void CompileID (string id, XmlSchemaObject xso, Hashtable idCollection, ValidationEventHandler h) { //check if the string conforms to http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/datatypes.html#ID // 1. ID must be a NCName // 2. ID must be unique in the schema if(id == null) return; if(!CheckNCName(id)) xso.error(h,id+" is not a valid id attribute"); else if(idCollection.ContainsKey(id)) xso.error(h,"Duplicate id attribute "+id); else idCollection.Add(id,xso); }
internal static XmlSchemaGroupRef Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaGroupRef xmlSchemaGroupRef = new XmlSchemaGroupRef(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaGroup.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaGroupRef.LineNumber = reader.LineNumber; xmlSchemaGroupRef.LinePosition = reader.LinePosition; xmlSchemaGroupRef.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaGroupRef.Id = reader.Value; } else if (reader.Name == "ref") { Exception ex; xmlSchemaGroupRef.refName = XmlSchemaUtil.ReadQNameAttribute(reader, out ex); if (ex != null) { XmlSchemaObject.error(h, reader.Value + " is not a valid value for ref attribute", ex); } } else if (reader.Name == "maxOccurs") { try { xmlSchemaGroupRef.MaxOccursString = reader.Value; } catch (Exception innerException) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for maxOccurs", innerException); } } else if (reader.Name == "minOccurs") { try { xmlSchemaGroupRef.MinOccursString = reader.Value; } catch (Exception innerException2) { XmlSchemaObject.error(h, reader.Value + " is an invalid value for minOccurs", innerException2); } } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for group", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaGroupRef); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaGroupRef); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "group") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaGroupRef.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaGroupRef.Annotation = xmlSchemaAnnotation; } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaGroupRef); }
internal static XmlSchemaSimpleTypeUnion Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaSimpleTypeUnion xmlSchemaSimpleTypeUnion = new XmlSchemaSimpleTypeUnion(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "union") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaSimpleTypeUnion.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaSimpleTypeUnion.LineNumber = reader.LineNumber; xmlSchemaSimpleTypeUnion.LinePosition = reader.LinePosition; xmlSchemaSimpleTypeUnion.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaSimpleTypeUnion.Id = reader.Value; } else if (reader.Name == "memberTypes") { string[] array = XmlSchemaUtil.SplitList(reader.Value); xmlSchemaSimpleTypeUnion.memberTypes = new XmlQualifiedName[array.Length]; for (int i = 0; i < array.Length; i++) { Exception ex; xmlSchemaSimpleTypeUnion.memberTypes[i] = XmlSchemaUtil.ToQName(reader, array[i], out ex); if (ex != null) { XmlSchemaObject.error(h, "'" + array[i] + "' is not a valid memberType", ex); } } } else if ((reader.NamespaceURI == string.Empty && reader.Name != "xmlns") || reader.NamespaceURI == "http://www.w3.org/2001/XMLSchema") { XmlSchemaObject.error(h, reader.Name + " is not a valid attribute for union", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaSimpleTypeUnion); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaSimpleTypeUnion); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "union") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaSimpleTypeUnion.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaSimpleTypeUnion.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "simpleType") { num = 2; XmlSchemaSimpleType xmlSchemaSimpleType = XmlSchemaSimpleType.Read(reader, h); if (xmlSchemaSimpleType != null) { xmlSchemaSimpleTypeUnion.baseTypes.Add(xmlSchemaSimpleType); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaSimpleTypeUnion); }