Inheritance: XmlSchemaIdentityConstraint
 void Write47_XmlSchemaKey(XmlSchemaKey o) {
     if ((object)o == null) return;
     System.Type t = o.GetType();
     WriteStartElement("key");
     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();
 }
Esempio n. 2
0
        /// <summary>
        /// Schemas the key. Not used currently
        /// </summary>
        /// <returns>key a </returns>
        public static XmlSchemaKey SchemaKey()
        {
            var elementKey = new XmlSchemaKey
                                 {
                                     Name = "AccountKey",
                                     Selector = new XmlSchemaXPath
                                                    {
                                                        XPath = "r:parts/r:part"
                                                    }
                                 };

            {
                var field = new XmlSchemaXPath
                                {
                                    XPath = "@number"
                                };

                elementKey.Fields.Add(field);
            }

            return elementKey;
        }
 protected override void Visit(XmlSchemaKey key)
 {
     _writer.WriteConstraintRow(_context, ArtItem.Key, "Key", key);
 }
Esempio n. 4
0
        /*
         * internal new void error(ValidationEventHandler handle, string message)
         * {
         *  errorCount++;
         *  ValidationHandler.RaiseValidationError(handle, this, message);
         * }
         */

        //<key
        //  id = ID
        //  name = NCName
        //  {any attributes with non-schema namespace . . .}>
        //  Content: (annotation?, (selector, field+))
        //</key>
        internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h)
        {
            XmlSchemaKey key = new XmlSchemaKey();

            reader.MoveToElement();

            if (reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
            {
                error(h, "Should not happen :1: XmlSchemaKey.Read, name=" + reader.Name, null);
                reader.Skip();
                return(null);
            }

            key.LineNumber   = reader.LineNumber;
            key.LinePosition = reader.LinePosition;
            key.SourceUri    = reader.BaseURI;

            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "id")
                {
                    key.Id = reader.Value;
                }
                else if (reader.Name == "name")
                {
                    key.Name = reader.Value;
                }
                else if ((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
                {
                    error(h, reader.Name + " is not a valid attribute for key", null);
                }
                else
                {
                    XmlSchemaUtil.ReadUnhandledAttribute(reader, key);
                }
            }

            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                return(key);
            }

            //  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: XmlSchemaKey.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)
                    {
                        key.Annotation = annotation;
                    }
                    continue;
                }
                if (level <= 2 && reader.LocalName == "selector")
                {
                    level = 3;
                    XmlSchemaXPath selector = XmlSchemaXPath.Read(reader, h, "selector");
                    if (selector != null)
                    {
                        key.Selector = selector;
                    }
                    continue;
                }
                if (level <= 3 && reader.LocalName == "field")
                {
                    level = 3;
                    if (key.Selector == null)
                    {
                        error(h, "selector must be defined before field declarations", null);
                    }
                    XmlSchemaXPath field = XmlSchemaXPath.Read(reader, h, "field");
                    if (field != null)
                    {
                        key.Fields.Add(field);
                    }
                    continue;
                }
                reader.RaiseInvalidElementError();
            }
            return(key);
        }
        internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h)
        {
            XmlSchemaKey xmlSchemaKey = new XmlSchemaKey();

            reader.MoveToElement();
            if (reader.NamespaceURI != "http://www.w3.org/2001/XMLSchema" || reader.LocalName != "key")
            {
                XmlSchemaObject.error(h, "Should not happen :1: XmlSchemaKey.Read, name=" + reader.Name, null);
                reader.Skip();
                return(null);
            }
            xmlSchemaKey.LineNumber   = reader.LineNumber;
            xmlSchemaKey.LinePosition = reader.LinePosition;
            xmlSchemaKey.SourceUri    = reader.BaseURI;
            while (reader.MoveToNextAttribute())
            {
                if (reader.Name == "id")
                {
                    xmlSchemaKey.Id = reader.Value;
                }
                else if (reader.Name == "name")
                {
                    xmlSchemaKey.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 key", null);
                }
                else
                {
                    XmlSchemaUtil.ReadUnhandledAttribute(reader, xmlSchemaKey);
                }
            }
            reader.MoveToElement();
            if (reader.IsEmptyElement)
            {
                return(xmlSchemaKey);
            }
            int num = 1;

            while (reader.ReadNextElement())
            {
                if (reader.NodeType == XmlNodeType.EndElement)
                {
                    if (reader.LocalName != "key")
                    {
                        XmlSchemaObject.error(h, "Should not happen :2: XmlSchemaKey.Read, name=" + reader.Name, null);
                    }
                    break;
                }
                if (num <= 1 && reader.LocalName == "annotation")
                {
                    num = 2;
                    XmlSchemaAnnotation xmlSchemaAnnotation = XmlSchemaAnnotation.Read(reader, h);
                    if (xmlSchemaAnnotation != null)
                    {
                        xmlSchemaKey.Annotation = xmlSchemaAnnotation;
                    }
                }
                else if (num <= 2 && reader.LocalName == "selector")
                {
                    num = 3;
                    XmlSchemaXPath xmlSchemaXPath = XmlSchemaXPath.Read(reader, h, "selector");
                    if (xmlSchemaXPath != null)
                    {
                        xmlSchemaKey.Selector = xmlSchemaXPath;
                    }
                }
                else if (num <= 3 && reader.LocalName == "field")
                {
                    num = 3;
                    if (xmlSchemaKey.Selector == null)
                    {
                        XmlSchemaObject.error(h, "selector must be defined before field declarations", null);
                    }
                    XmlSchemaXPath xmlSchemaXPath2 = XmlSchemaXPath.Read(reader, h, "field");
                    if (xmlSchemaXPath2 != null)
                    {
                        xmlSchemaKey.Fields.Add(xmlSchemaXPath2);
                    }
                }
                else
                {
                    reader.RaiseInvalidElementError();
                }
            }
            return(xmlSchemaKey);
        }
 private void Write47_XmlSchemaKey(XmlSchemaKey o)
 {
     if (o != null)
     {
         o.GetType();
         this.WriteStartElement("key");
         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(XmlSchemaKey key)
 {
     Traverse(key.Selector);
     Traverse(key.Fields);
 }
Esempio n. 8
0
		/*
		internal new void error(ValidationEventHandler handle, string message)
		{
			errorCount++;
			ValidationHandler.RaiseValidationError(handle, this, message);
		}
		*/

		//<key 
		//  id = ID 
		//  name = NCName 
		//  {any attributes with non-schema namespace . . .}>
		//  Content: (annotation?, (selector, field+))
		//</key>
		internal static XmlSchemaKey Read(XmlSchemaReader reader, ValidationEventHandler h)
		{
			XmlSchemaKey key = new XmlSchemaKey();
			reader.MoveToElement();

			if(reader.NamespaceURI != XmlSchema.Namespace || reader.LocalName != xmlname)
			{
				error(h,"Should not happen :1: XmlSchemaKey.Read, name="+reader.Name,null);
				reader.Skip();
				return null;
			}

			key.LineNumber = reader.LineNumber;
			key.LinePosition = reader.LinePosition;
			key.SourceUri = reader.BaseURI;

			while(reader.MoveToNextAttribute())
			{
				if(reader.Name == "id")
				{
					key.Id = reader.Value;
				}
				else if(reader.Name == "name")
				{
					key.Name = reader.Value;
				}
				else if((reader.NamespaceURI == "" && reader.Name != "xmlns") || reader.NamespaceURI == XmlSchema.Namespace)
				{
					error(h,reader.Name + " is not a valid attribute for key",null);
				}
				else
				{
					XmlSchemaUtil.ReadUnhandledAttribute(reader,key);
				}
			}
			
			reader.MoveToElement();
			if(reader.IsEmptyElement)
				return key;

			//  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: XmlSchemaKey.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)
						key.Annotation = annotation;
					continue;
				}
				if(level <= 2 && reader.LocalName == "selector")
				{
					level = 3;
					XmlSchemaXPath selector = XmlSchemaXPath.Read(reader,h,"selector");
					if(selector != null)
						key.Selector = selector;
					continue;
				}
				if(level <= 3 && reader.LocalName == "field")
				{
					level = 3;
					if(key.Selector == null)
						error(h,"selector must be defined before field declarations",null);
					XmlSchemaXPath field = XmlSchemaXPath.Read(reader,h,"field");
					if(field != null)
						key.Fields.Add(field);
					continue;
				}
				reader.RaiseInvalidElementError();
			}
			return key;
		}
 private void Write49_XmlSchemaKey(string n, string ns, XmlSchemaKey o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(XmlSchemaKey)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.EscapeName = false;
         base.WriteStartElement(n, ns, o, false, o.Namespaces);
         if (needType)
         {
             base.WriteXsiType("XmlSchemaKey", "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);
     }
 }