X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fclass%2FSystem.XML%2FSystem.Xml.Schema%2FXmlSchemaUnique.cs;h=2ed671986a9d7b5d7d5f40fb3e47331f8fb5cf60;hb=105bb9386687bcf106c6591fdc309eec456bf6cc;hp=c77336f68fa5a18046bc86140159f008a37f4c68;hpb=04d1b4116331e3813b8f75304f714a5d61ba1214;p=mono.git diff --git a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs index c77336f68fa..2ed671986a9 100644 --- a/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs +++ b/mcs/class/System.XML/System.Xml.Schema/XmlSchemaUnique.cs @@ -1,5 +1,5 @@ -// Author: Dwivedi, Ajay kumar -// Adwiv@Yahoo.com +// Author: Dwivedi, Ajay kumar +// Adwiv@Yahoo.com // // Permission is hereby granted, free of charge, to any person obtaining @@ -21,127 +21,127 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // -using System; -using System.Xml; - -namespace System.Xml.Schema -{ - /// - /// Summary description for XmlSchemaUnique. - /// - public class XmlSchemaUnique : XmlSchemaIdentityConstraint - { - const string xmlname = "unique"; - - public XmlSchemaUnique() - { - } - /// - /// 1. name must be present - /// 2. selector and field must be present - /// - internal override int Compile(ValidationEventHandler h, XmlSchema schema) - { - return base.Compile(h,schema); - } - - internal override int Validate(ValidationEventHandler h, XmlSchema schema) - { - return errorCount; - } - - /* - internal new void error(ValidationEventHandler handle, string message) - { - errorCount++; - ValidationHandler.RaiseValidationError(handle, this, message); - } - */ - // - // Content: (annotation?, (selector, field+)) - // - 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; - } - } -} +using System; +using System.Xml; + +namespace System.Xml.Schema +{ + /// + /// Summary description for XmlSchemaUnique. + /// + public class XmlSchemaUnique : XmlSchemaIdentityConstraint + { + const string xmlname = "unique"; + + public XmlSchemaUnique() + { + } + /// + /// 1. name must be present + /// 2. selector and field must be present + /// + internal override int Compile(ValidationEventHandler h, XmlSchema schema) + { + return base.Compile(h,schema); + } + + internal override int Validate(ValidationEventHandler h, XmlSchema schema) + { + return errorCount; + } + + /* + internal new void error(ValidationEventHandler handle, string message) + { + errorCount++; + ValidationHandler.RaiseValidationError(handle, this, message); + } + */ + // + // Content: (annotation?, (selector, field+)) + // + 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; + } + } +}