void Write51_XmlSchemaUnique(XmlSchemaUnique o) { if ((object)o == null) return; System.Type t = o.GetType(); WriteStartElement("unique"); WriteAttribute(@"id", @"", ((System.String)o.@Id)); WriteAttribute(@"name", @"", ((System.String)o.@Name)); WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o); Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation); Write49_XmlSchemaXPath("selector", "", (XmlSchemaXPath)o.@Selector); XmlSchemaObjectCollection a = (XmlSchemaObjectCollection)o.@Fields; if (a != null) { for (int ia = 0; ia < a.Count; ia++) { Write49_XmlSchemaXPath("field", "", (XmlSchemaXPath)a[ia]); } } WriteEndElement(); }
/* * 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); }
protected override void Visit(XmlSchemaUnique unique) { _writer.WriteConstraintRow(_context, ArtItem.Unique, "Unique", unique); }
internal static XmlSchemaUnique Read(XmlSchemaReader reader, ValidationEventHandler h) { XmlSchemaUnique xmlSchemaUnique = new XmlSchemaUnique(); reader.MoveToElement(); if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "unique") { XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaUnique.Read, name=" + reader.Name, null); reader.Skip(); return(null); } xmlSchemaUnique.LineNumber = reader.LineNumber; xmlSchemaUnique.LinePosition = reader.LinePosition; xmlSchemaUnique.SourceUri = reader.BaseURI; while (reader.MoveToNextAttribute()) { if (reader.Name == "id") { xmlSchemaUnique.Id = reader.Value; } else if (reader.Name == "name") { xmlSchemaUnique.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 unique", null); } else { XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaUnique); } } reader.MoveToElement(); if (reader.IsEmptyElement) { return(xmlSchemaUnique); } int num = 1; while (reader.ReadNextElement()) { if (reader.NodeType == XmlNodeType.EndElement) { if (reader.LocalName != "unique") { XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaUnion.Read, name=" + reader.Name, null); } break; } if (num <= 1 && reader.LocalName == "annotation") { num = 2; XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h); if (xmlSchemaAnnotation != null) { xmlSchemaUnique.Annotation = xmlSchemaAnnotation; } } else if (num <= 2 && reader.LocalName == "selector") { num = 3; XmlSchemaXPath xmlSchemaXPath = XmlSchemaXPath.Read(reader, h, "selector"); if (xmlSchemaXPath != null) { xmlSchemaUnique.Selector = xmlSchemaXPath; } } else if (num <= 3 && reader.LocalName == "field") { num = 3; if (xmlSchemaUnique.Selector == null) { XmlSchemaObject.error(h, "selector must be defined before field declarations", null); } XmlSchemaXPath xmlSchemaXPath2 = XmlSchemaXPath.Read(reader, h, "field"); if (xmlSchemaXPath2 != null) { xmlSchemaUnique.Fields.Add(xmlSchemaXPath2); } } else { reader.RaiseInvalidElementError(); } } return(xmlSchemaUnique); }
private void Write51_XmlSchemaUnique(XmlSchemaUnique o) { if (o != null) { o.GetType(); this.WriteStartElement("unique"); this.WriteAttribute("id", "", o.Id); this.WriteAttribute("name", "", o.Name); this.WriteAttributes(o.UnhandledAttributes, o); this.Write5_XmlSchemaAnnotation(o.Annotation); this.Write49_XmlSchemaXPath("selector", "", o.Selector); XmlSchemaObjectCollection fields = o.Fields; if (fields != null) { for (int i = 0; i < fields.Count; i++) { this.Write49_XmlSchemaXPath("field", "", (XmlSchemaXPath) fields[i]); } } this.WriteEndElement(); } }
protected virtual void Visit(XmlSchemaUnique unique) { Traverse(unique.Selector); Traverse(unique.Fields); }
/* 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; }
private void Write50_XmlSchemaUnique(string n, string ns, XmlSchemaUnique o, bool isNullable, bool needType) { if (o == null) { if (isNullable) { base.WriteNullTagLiteral(n, ns); } } else { if (!needType && !(o.GetType() == typeof(XmlSchemaUnique))) { throw base.CreateUnknownTypeException(o); } base.EscapeName = false; base.WriteStartElement(n, ns, o, false, o.Namespaces); if (needType) { base.WriteXsiType("XmlSchemaUnique", "http://www.w3.org/2001/XMLSchema"); } base.WriteAttribute("id", "", o.Id); XmlAttribute[] unhandledAttributes = o.UnhandledAttributes; if (unhandledAttributes != null) { for (int i = 0; i < unhandledAttributes.Length; i++) { XmlAttribute node = unhandledAttributes[i]; base.WriteXmlAttribute(node, o); } } base.WriteAttribute("name", "", o.Name); this.Write11_XmlSchemaAnnotation("annotation", "http://www.w3.org/2001/XMLSchema", o.Annotation, false, false); this.Write47_XmlSchemaXPath("selector", "http://www.w3.org/2001/XMLSchema", o.Selector, false, false); XmlSchemaObjectCollection fields = o.Fields; if (fields != null) { for (int j = 0; j < fields.Count; j++) { this.Write47_XmlSchemaXPath("field", "http://www.w3.org/2001/XMLSchema", (XmlSchemaXPath) fields[j], false, false); } } base.WriteEndElement(o); } }