Inheritance: XmlSchemaSimpleTypeContent
コード例 #1
0
        protected override void Visit(XmlSchemaSimpleTypeUnion union)
        {
            PushNode(SimpleTypeStructureNodeType.Union, union);

            foreach (var baseMemberType in union.BaseMemberTypes)
                Traverse(baseMemberType);

            PopNode();
        }
コード例 #2
0
        internal override XmlSchemaObject Clone()
        {
            if ((this.memberTypes == null) || (this.memberTypes.Length <= 0))
            {
                return(this);
            }
            XmlSchemaSimpleTypeUnion union = (XmlSchemaSimpleTypeUnion)base.MemberwiseClone();

            XmlQualifiedName[] nameArray = new XmlQualifiedName[this.memberTypes.Length];
            for (int i = 0; i < this.memberTypes.Length; i++)
            {
                nameArray[i] = this.memberTypes[i].Clone();
            }
            union.MemberTypes = nameArray;
            return(union);
        }
コード例 #3
0
        internal override XmlSchemaObject Clone()
        {
            if (_memberTypes != null && _memberTypes.Length > 0)
            { //Only if the union has MemberTypes defined
                XmlSchemaSimpleTypeUnion newUnion  = (XmlSchemaSimpleTypeUnion)MemberwiseClone();
                XmlQualifiedName[]       newQNames = new XmlQualifiedName[_memberTypes.Length];

                for (int i = 0; i < _memberTypes.Length; i++)
                {
                    newQNames[i] = _memberTypes[i].Clone();
                }
                newUnion.MemberTypes = newQNames;
                return(newUnion);
            }
            return(this);
        }
コード例 #4
0
		/// <summary>
		/// Creates a simple type that is the union of two other types
		/// </summary>
		/// <param name="Name">The name of the type</param>
		/// <param name="ValidTypes">List of valid types for the union</param>
		/// <returns>A simple type which will match the given pattern</returns>
		static XmlSchemaSimpleType CreateSimpleTypeFromUnion(string Name, params XmlSchemaType[] ValidTypes)
		{
			XmlSchemaSimpleTypeUnion Union = new XmlSchemaSimpleTypeUnion();
			foreach (XmlSchemaType ValidType in ValidTypes)
			{
				Union.BaseTypes.Add(ValidType);
			}

			XmlSchemaSimpleType UnionType = new XmlSchemaSimpleType();
			UnionType.Name = Name;
			UnionType.Content = Union;
			return UnionType;
		}
コード例 #5
0
		void GetAttributeValueCompletionData (XmlCompletionDataList data, XmlSchemaSimpleTypeUnion union)
		{
			foreach (XmlSchemaObject schemaObject in union.BaseTypes) {
				var simpleType = schemaObject as XmlSchemaSimpleType;
				if (simpleType != null)
					GetAttributeValueCompletionData (data, simpleType);
			}
		}		
コード例 #6
0
        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);
        }
コード例 #7
0
        //<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);
        }
コード例 #8
0
ファイル: XsdBuilder.cs プロジェクト: uQr/referencesource
 private void SetContainer(State state, object container) {
     switch (state) {
         case State.Root:
             break;
         case State.Schema:
             break;
         case State.Annotation:
             this.annotation = (XmlSchemaAnnotation)container;
             break;
         case State.Include:
             this.include = (XmlSchemaInclude)container;
             break;
         case State.Import:
             this.import = (XmlSchemaImport)container;
             break;
         case State.Element:
             this.element = (XmlSchemaElement)container;
             break;
         case State.Attribute:
             this.attribute = (XmlSchemaAttribute)container;
             break;
         case State.AttributeGroup:
             this.attributeGroup = (XmlSchemaAttributeGroup)container;
             break;
         case State.AttributeGroupRef:
             this.attributeGroupRef = (XmlSchemaAttributeGroupRef)container;
             break;
         case State.AnyAttribute:
             this.anyAttribute = (XmlSchemaAnyAttribute)container;
             break;
         case State.Group:
             this.group = (XmlSchemaGroup)container;
             break;
         case State.GroupRef:
             this.groupRef = (XmlSchemaGroupRef)container;
             break;
         case State.All:
             this.all = (XmlSchemaAll)container;
             break;
         case State.Choice:
             this.choice = (XmlSchemaChoice)container;
             break;
         case State.Sequence:
             this.sequence = (XmlSchemaSequence)container;
             break;
         case State.Any:
             this.anyElement = (XmlSchemaAny)container;
             break;
         case State.Notation:
             this.notation = (XmlSchemaNotation)container;
             break;
         case State.SimpleType:
             this.simpleType = (XmlSchemaSimpleType)container;
             break;
         case State.ComplexType:
             this.complexType = (XmlSchemaComplexType)container;
             break;
         case State.ComplexContent:
             this.complexContent = (XmlSchemaComplexContent)container;
             break;
         case State.ComplexContentExtension:
             this.complexContentExtension = (XmlSchemaComplexContentExtension)container;
             break;
         case State.ComplexContentRestriction:
             this.complexContentRestriction = (XmlSchemaComplexContentRestriction)container;
             break;
         case State.SimpleContent:
             this.simpleContent = (XmlSchemaSimpleContent)container;
             break;
         case State.SimpleContentExtension:
             this.simpleContentExtension = (XmlSchemaSimpleContentExtension)container;
             break;
         case State.SimpleContentRestriction:
             this.simpleContentRestriction = (XmlSchemaSimpleContentRestriction)container;
             break;
         case State.SimpleTypeUnion:
             this.simpleTypeUnion = (XmlSchemaSimpleTypeUnion)container;
             break;
         case State.SimpleTypeList:
             this.simpleTypeList = (XmlSchemaSimpleTypeList)container;
             break;
         case State.SimpleTypeRestriction:
             this.simpleTypeRestriction = (XmlSchemaSimpleTypeRestriction)container;
             break;
         case State.Unique:
         case State.Key:
         case State.KeyRef:
             this.identityConstraint = (XmlSchemaIdentityConstraint)container;
             break;
         case State.Selector:
         case State.Field:
             this.xpath = (XmlSchemaXPath)container;
             break;
         case State.MinExclusive:
         case State.MinInclusive:
         case State.MaxExclusive:
         case State.MaxInclusive:
         case State.TotalDigits:
         case State.FractionDigits:
         case State.Length:
         case State.MinLength:
         case State.MaxLength:
         case State.Enumeration:
         case State.Pattern:
         case State.WhiteSpace:
             this.facet = (XmlSchemaFacet)container;
             break;
         case State.AppInfo:
             this.appInfo = (XmlSchemaAppInfo)container;
             break;
         case State.Documentation:
             this.documentation = (XmlSchemaDocumentation)container;
             break;
         case State.Redefine:
             this.redefine = (XmlSchemaRedefine)container;
             break;
         default:
             Debug.Assert(false, "State is " + state);
             break;
     }
 }
コード例 #9
0
		XmlCompletionItemCollection GetAttributeValueCompletion(XmlSchemaSimpleTypeUnion union)
		{
			XmlCompletionItemCollection completionItems = new XmlCompletionItemCollection();
			
			foreach (XmlSchemaObject schemaObject in union.BaseTypes) {
				XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
				if (simpleType != null) {
					completionItems.AddRange(GetAttributeValueCompletion(simpleType));
				}
			}
			
			if (union.BaseMemberTypes != null) {
				foreach (XmlSchemaSimpleType simpleType in union.BaseMemberTypes) {
					completionItems.AddRange(GetAttributeValueCompletion(simpleType));
				}
			}
			
			return completionItems;
		}
コード例 #10
0
 protected virtual void Visit(XmlSchemaSimpleTypeUnion union)
 {
     foreach (var simpleType in union.BaseMemberTypes)
         Traverse(simpleType);
 }
コード例 #11
0
		//<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;
		}
コード例 #12
0
 void Handler.BeginSimpleTypeUnion(XmlSchemaSimpleTypeUnion union)
 {
 }
コード例 #13
0
            protected override void Visit(XmlSchemaSimpleTypeUnion union)
            {
                foreach (var baseMemberType in union.BaseMemberTypes)
                {
                    if (!baseMemberType.QualifiedName.IsEmpty)
                        continue;

                    _writer.WriteHtmlArtItemWithText(ArtItem.Union, "Union");
                    return;
                }

                _writer.StartHtmlArtItem(ArtItem.Union);

                var isFirst = true;
                foreach (var baseMemberType in union.BaseMemberTypes)
                {
                    if (isFirst)
                    {
                        _writer.WriteString(", ");
                        isFirst = false;
                    }

                    var topic = _context.TopicManager.GetTopic(baseMemberType);
                    if (topic != null)
                    {
                        _writer.WriteHtmlTopicLink(topic);
                    }
                    else
                    {
                        _writer.WriteString(baseMemberType.QualifiedName.Name);
                    }
                }

                _writer.EndHtmlArtItem();
            }
 private void Write33_XmlSchemaSimpleTypeUnion(string n, string ns, XmlSchemaSimpleTypeUnion o, bool isNullable, bool needType)
 {
     if (o == null)
     {
         if (isNullable)
         {
             base.WriteNullTagLiteral(n, ns);
         }
     }
     else
     {
         if (!needType && !(o.GetType() == typeof(XmlSchemaSimpleTypeUnion)))
         {
             throw base.CreateUnknownTypeException(o);
         }
         base.EscapeName = false;
         base.WriteStartElement(n, ns, o, false, o.Namespaces);
         if (needType)
         {
             base.WriteXsiType("XmlSchemaSimpleTypeUnion", "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);
             }
         }
         XmlQualifiedName[] memberTypes = o.MemberTypes;
         if (memberTypes != null)
         {
             StringBuilder builder = new StringBuilder();
             for (int j = 0; j < memberTypes.Length; j++)
             {
                 XmlQualifiedName xmlQualifiedName = memberTypes[j];
                 if (j != 0)
                 {
                     builder.Append(" ");
                 }
                 builder.Append(base.FromXmlQualifiedName(xmlQualifiedName));
             }
             if (builder.Length != 0)
             {
                 base.WriteAttribute("memberTypes", "", builder.ToString());
             }
         }
         this.Write11_XmlSchemaAnnotation("annotation", "http://www.w3.org/2001/XMLSchema", o.Annotation, false, false);
         XmlSchemaObjectCollection baseTypes = o.BaseTypes;
         if (baseTypes != null)
         {
             for (int k = 0; k < baseTypes.Count; k++)
             {
                 this.Write34_XmlSchemaSimpleType("simpleType", "http://www.w3.org/2001/XMLSchema", (XmlSchemaSimpleType) baseTypes[k], false, false);
             }
         }
         base.WriteEndElement(o);
     }
 }
コード例 #15
0
ファイル: Navigator.cs プロジェクト: philbooth/SchemaBrute
        private void NavigateSimpleTypeUnion(XmlSchemaSimpleTypeUnion simpleTypeUnion)
        {
            handler.BeginSimpleTypeUnion(simpleTypeUnion);

            foreach(XmlSchemaSimpleType simpleType in simpleTypeUnion.BaseMemberTypes)
                NavigateSimpleType(simpleType);

            handler.EndSimpleTypeUnion();
        }
コード例 #16
0
        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);
        }
コード例 #17
0
ファイル: XsXsdGenerator.cs プロジェクト: xsharper/xsharper
        private static void createEnum(PropertyInfo pi, Dictionary<Type, XmlSchemaType> xmlTypes, XmlSchema xmlSchema)
        {
            // Create enum
            var res = new XmlSchemaSimpleTypeRestriction();
            res.BaseTypeName = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.NmToken).QualifiedName;

            foreach (var o in Enum.GetNames(pi.PropertyType))
            {
                res.Facets.Add(new XmlSchemaEnumerationFacet
                    {
                        Value = (o.Substring(0, 1).ToLower() + o.Substring(1))
                });
            }

            XmlSchemaSimpleType st = new XmlSchemaSimpleType
            {
                Content = res
            };

            // For flags must create a union of the values & string
            if (CustomAttributeHelper.Has<System.FlagsAttribute>(pi.PropertyType))
            {
                XmlSchemaSimpleType st2 = new XmlSchemaSimpleType();
                st2.Name = getXmlTypeName(pi.PropertyType);

                var union = new XmlSchemaSimpleTypeUnion();

                XmlSchemaSimpleType st3 = new XmlSchemaSimpleType();
                var res3 = new XmlSchemaSimpleTypeRestriction();
                res3.BaseTypeName = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.String).QualifiedName;
                st3.Content = res3;

                union.BaseTypes.Add(st);
                union.BaseTypes.Add(st3);

                st2.Content = union;
                xmlSchema.Items.Add(st2);
                xmlTypes[pi.PropertyType] = st2;
            }
            else
            {
                st.Name = getXmlTypeName(pi.PropertyType);
                xmlSchema.Items.Add(st);
                xmlTypes[pi.PropertyType] = st;
            }
        }
 private void Write12_XmlSchemaSimpleTypeUnion(XmlSchemaSimpleTypeUnion o)
 {
     if (o != null)
     {
         this.WriteStartElement("union");
         this.WriteAttribute("id", "", o.Id);
         this.WriteAttributes(o.UnhandledAttributes, o);
         if (o.MemberTypes != null)
         {
             ArrayList list = new ArrayList();
             for (int i = 0; i < o.MemberTypes.Length; i++)
             {
                 list.Add(o.MemberTypes[i]);
             }
             list.Sort(new QNameComparer());
             this.w.Append(",");
             this.w.Append("memberTypes=");
             for (int j = 0; j < list.Count; j++)
             {
                 this.w.Append(((XmlQualifiedName) list[j]).ToString());
                 this.w.Append(",");
             }
         }
         this.Write5_XmlSchemaAnnotation(o.Annotation);
         this.WriteSortedItems(o.BaseTypes);
         this.WriteEndElement();
     }
 }
コード例 #19
0
        //<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);
        }
コード例 #20
0
ファイル: ConformanceChecker.cs プロジェクト: nobled/mono
		public virtual void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeUnion value) {}
コード例 #21
0
		public override void Check (ConformanceCheckContext ctx, XmlSchemaSimpleTypeUnion value)
		{
			foreach (XmlQualifiedName name in value.MemberTypes)
				CheckSchemaQName (ctx, value, name);
		}
コード例 #22
0
		XmlCompletionDataCollection GetAttributeValueCompletionData(XmlSchemaSimpleTypeUnion union)
		{
			XmlCompletionDataCollection data = new XmlCompletionDataCollection();
			
			foreach (XmlSchemaObject schemaObject in union.BaseTypes) {
				XmlSchemaSimpleType simpleType = schemaObject as XmlSchemaSimpleType;
				if (simpleType != null) {
					data.AddRange(GetAttributeValueCompletionData(simpleType));
				}
			}

			return data;
		}		
コード例 #23
0
        void Write12_XmlSchemaSimpleTypeUnion(XmlSchemaSimpleTypeUnion o) {
            if ((object)o == null) return;
            WriteStartElement("union");
            
            WriteAttribute(@"id", @"", ((System.String)o.@Id));
            WriteAttributes((XmlAttribute[])o.@UnhandledAttributes, o);

            if (o.MemberTypes != null) {
                ArrayList list = new ArrayList();
                for (int i = 0; i < o.MemberTypes.Length; i++) {
                    list.Add(o.MemberTypes[i]);
                }
                list.Sort(new QNameComparer());
            
                w.Append(",");
                w.Append("memberTypes=");

                for (int i = 0; i < list.Count; i++) {
                    XmlQualifiedName q = (XmlQualifiedName)list[i];
                    w.Append(q.ToString());
                    w.Append(",");
                }
            }
            Write5_XmlSchemaAnnotation((XmlSchemaAnnotation)o.@Annotation);
            WriteSortedItems(o.@BaseTypes);
            WriteEndElement();
        }
コード例 #24
0
ファイル: HandlerStub.cs プロジェクト: philbooth/SchemaBrute
 void Handler.BeginSimpleTypeUnion(XmlSchemaSimpleTypeUnion union)
 {
     counts.Increment(Counts.Index.SimpleTypeUnion);
 }