當前位置: 首頁>>代碼示例>>C#>>正文


C# Schema.XmlSchemaAttribute類代碼示例

本文整理匯總了C#中System.Xml.Schema.XmlSchemaAttribute的典型用法代碼示例。如果您正苦於以下問題:C# XmlSchemaAttribute類的具體用法?C# XmlSchemaAttribute怎麽用?C# XmlSchemaAttribute使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


XmlSchemaAttribute類屬於System.Xml.Schema命名空間,在下文中一共展示了XmlSchemaAttribute類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildAttribute

        protected void BuildAttribute( XmlSchemaAttribute attribute,
                                       ObjectDef objectDef )
        {
            FieldDef def = null;
            bool isEnum;
            string dataType =
                GetClassTypeFromDataType
                    ( attribute.AttributeSchemaType, attribute.QualifiedName.Name, objectDef.Name,
                      out isEnum );
            if ( isEnum ) {
                def = objectDef.DefineAttr( attribute.QualifiedName.Name, null );
                def.SetEnum( dataType );
            }
            else {
                def = objectDef.DefineAttr( attribute.QualifiedName.Name, dataType );
            }

            if ( attribute.Use == XmlSchemaUse.Required ) {
                def.SetFlags( "R" );
            }
            else {
                def.SetFlags( "O" );
            }
            setAnnotation( def, attribute.Annotation );
            // TODO: See if the data type is an enumeration
            //System.Diagnostics.Debug.Assert( ! ( attribute.AttributeType is xmlschemdata
        }
開發者ID:rafidzal,項目名稱:OpenADK-csharp,代碼行數:27,代碼來源:SifSchema.cs

示例2: AttributeForm

 private XmlSchemaForm AttributeForm(string ns, XmlSchemaAttribute attribute)
 {
     if (attribute.Form != XmlSchemaForm.None)
     {
         return attribute.Form;
     }
     XmlSchemaObject parent = attribute;
     while (parent.Parent != null)
     {
         parent = parent.Parent;
     }
     XmlSchema schema = parent as XmlSchema;
     if (schema != null)
     {
         if ((ns == null) || (ns.Length == 0))
         {
             if (schema.AttributeFormDefault != XmlSchemaForm.None)
             {
                 return schema.AttributeFormDefault;
             }
             return XmlSchemaForm.Unqualified;
         }
         XmlSchemas.Preprocess(schema);
         if ((attribute.QualifiedName.Namespace != null) && (attribute.QualifiedName.Namespace.Length != 0))
         {
             return XmlSchemaForm.Qualified;
         }
     }
     return XmlSchemaForm.Unqualified;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:30,代碼來源:XmlSchemaImporter.cs

示例3: AndSchema

		public static XmlSchemaElement AndSchema()
		{
			var type = new XmlSchemaComplexType();

			var any = new XmlSchemaAny();
			any.MinOccurs = 1;
			any.MaxOccursString = "unbounded";
			any.ProcessContents = XmlSchemaContentProcessing.Strict;
			any.Namespace = "##local";

			var sequence = new XmlSchemaSequence();
			type.Particle = sequence;
			sequence.Items.Add(any);

			var attrib = new XmlSchemaAttribute();
			attrib.Name = "expressionLanguage";
			attrib.Use = XmlSchemaUse.Optional;
			attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
			type.Attributes.Add(attrib);

			attrib = new XmlSchemaAttribute();
			attrib.Name = "failMessage";
			attrib.Use = XmlSchemaUse.Optional;
			attrib.SchemaTypeName = new XmlQualifiedName("string", "http://www.w3.org/2001/XMLSchema");
			type.Attributes.Add(attrib);

			var element = new XmlSchemaElement();
			element.Name = "and";
			element.SchemaType = type;

			return element;
		}
開發者ID:m-berkani,項目名稱:ClearCanvas,代碼行數:32,代碼來源:XmlSpecificationSchema.cs

示例4: ReplaceThisWith

 public static void ReplaceThisWith(this XmlSchemaAttribute that, XmlSchemaAttribute with) 
 {
     var gr = that.Parent as XmlSchemaComplexType;
     int idx = gr.Attributes.IndexOf(that);
     gr.Attributes.Insert(idx, with);
     gr.Attributes.Remove(that);
 }
開發者ID:alcardac,項目名稱:SDMXRI_WS_OF,代碼行數:7,代碼來源:DmlExtensions.cs

示例5: FixtureInit

		public override void FixtureInit()
		{
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			schemas.Add(SchemaCompletionData);
			XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, SchemaCompletionData, String.Empty);
			string xml = "<note xmlns='http://www.w3schools.com' name=''></note>";
			schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, xml.IndexOf("name"), provider);
		}
開發者ID:kingjiang,項目名稱:SharpDevelopLite,代碼行數:8,代碼來源:AttributeSelectedTestFixture.cs

示例6: Visit

        protected override void Visit(XmlSchemaAttribute attribute)
        {
            if (!attribute.RefName.IsEmpty ||
                attribute.Use == XmlSchemaUse.Prohibited)
                return;

            AddTopic(TopicType.Attribute, attribute.QualifiedName.Namespace, attribute, attribute.Name);
        }
開發者ID:sergey-steinvil,項目名稱:xsddoc,代碼行數:8,代碼來源:TopicBuilder.cs

示例7: FixtureInit

		public override void FixtureInit()
		{
			XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
			schemas.Add(SchemaCompletion);
			string xml = "<note xmlns='http://www.w3schools.com' name=''></note>";
			XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, null);
			schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, xml.IndexOf("name"));
		}
開發者ID:fanyjie,項目名稱:SharpDevelop,代碼行數:8,代碼來源:AttributeSelectedTestFixture.cs

示例8: Visit

        protected override void Visit(XmlSchemaAttribute attribute)
        {
            if (!attribute.RefName.IsEmpty)
                return;

            PushNamedObject(attribute);
            base.Visit(attribute);
            PopNamedObject();
        }
開發者ID:sergey-steinvil,項目名稱:xsddoc,代碼行數:9,代碼來源:TypeUsageFinder.cs

示例9: FixtureInit

		public override void FixtureInit()
		{
			XmlSchemaCompletionCollection schemas = new XmlSchemaCompletionCollection();
			schemas.Add(SchemaCompletion);
			XmlSchemaCompletion xsdSchemaCompletionData = new XmlSchemaCompletion(ResourceManager.ReadXsdSchema());
			schemas.Add(xsdSchemaCompletionData);
			
			string xml = GetSchema();			
			int index = xml.IndexOf("ref=\"dir\"");
			index = xml.IndexOf("dir", index);
			XmlSchemaDefinition schemaDefinition = new XmlSchemaDefinition(schemas, SchemaCompletion);
			schemaAttribute = (XmlSchemaAttribute)schemaDefinition.GetSelectedSchemaObject(xml, index);
		}
開發者ID:Bombadil77,項目名稱:SharpDevelop,代碼行數:13,代碼來源:AttributeReferenceSelectedTestFixture.cs

示例10: FixtureInit

		public override void FixtureInit()
		{
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			schemas.Add(SchemaCompletionData);
			XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
			schemas.Add(xsdSchemaCompletionData);
			XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty);
			
			string xml = GetSchema();			
			int index = xml.IndexOf("ref=\"dir\"");
			index = xml.IndexOf("dir", index);
			schemaAttribute = (XmlSchemaAttribute)XmlView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
		}
開發者ID:kingjiang,項目名稱:SharpDevelopLite,代碼行數:13,代碼來源:AttributeReferenceSelectedTestFixture.cs

示例11: FixtureInit

		public override void FixtureInit()
		{
			XmlSchemaCompletionDataCollection schemas = new XmlSchemaCompletionDataCollection();
			schemas.Add(SchemaCompletionData);
			XmlSchemaCompletionData xsdSchemaCompletionData = new XmlSchemaCompletionData(ResourceManager.GetXsdSchema());
			schemas.Add(xsdSchemaCompletionData);
			XmlCompletionDataProvider provider = new XmlCompletionDataProvider(schemas, xsdSchemaCompletionData, String.Empty, null);
			
			string xml = GetSchema();
			schemaAttribute = (XmlSchemaAttribute)XmlEditorView.GetSchemaObjectSelected(xml, xml.IndexOf("ref=\"name"), provider, SchemaCompletionData);
			
			int index = xml.IndexOf("ref=\"name");
			index = xml.IndexOf('n', index);
			referencedSchemaElement = (XmlSchemaElement)XmlEditorView.GetSchemaObjectSelected(xml, index, provider, SchemaCompletionData);
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:15,代碼來源:ElementReferenceSelectedTestFixture.cs

示例12: GetDataSchemas

        public XmlSchema GetDataSchemas(XmlSchema querySchema,IEnumerable<Registration> registrations)
        {
            var schema = new XmlSchema { TargetNamespace = RegistrationStorage.Dataspace };
            schema.Namespaces.Add("", RegistrationStorage.Dataspace);
            var guid = CreateGuidType();
            schema.Items.Add(guid);
            schema.Includes.Add(new XmlSchemaImport { Schema = querySchema, Namespace = querySchema.TargetNamespace });
            foreach (var registration in registrations)
            {
                var etype = new XmlSchemaComplexType
                {
                    Name = registration.ResourceName,
                    Annotation = new XmlSchemaAnnotation()
                };
                var doc = new XmlSchemaDocumentation { Markup = TextToNode(registration.ResourceType.FullName) };
                etype.Annotation.Items.Add(doc);
                etype.Block = XmlSchemaDerivationMethod.Extension;
                var idAttr = new XmlSchemaAttribute
                {
                    Name = "Id",
                    SchemaTypeName = new XmlQualifiedName(guid.Name, RegistrationStorage.Dataspace),
                    Use = XmlSchemaUse.Required
                };
                etype.Attributes.Add(idAttr);
                var noChildrenAttr = new XmlSchemaAttribute
                {
                    Name = RegistrationStorage.DefinitlyNoChildren,
                    SchemaType = XmlSchemaType.GetBuiltInSimpleType(XmlTypeCode.Boolean),
                    Use = XmlSchemaUse.Optional
                };
                etype.Attributes.Add(noChildrenAttr);
                if (querySchema.Items.OfType<XmlSchemaAttributeGroup>().Any(k => k.Name == etype.Name))
                {

                    var group = new XmlSchemaAttributeGroupRef();
                    group.RefName = new XmlQualifiedName(etype.Name.Replace(" ", "_"), querySchema.TargetNamespace);
                    etype.Attributes.Add(group);

                }
                schema.Items.Add(etype);
            }

            return schema;
        }
開發者ID:kayanme,項目名稱:Dataspace,代碼行數:44,代碼來源:DataSchemaBuilder.cs

示例13: AddAttribute

		public void AddAttribute (XmlSchemaAttribute attribute)
		{
			string name = attribute.Name;
			if (name == null) {
				var ns = attribute.RefName.Namespace;
				if (string.IsNullOrEmpty (ns))
					return;
				var prefix = nsMap.GetPrefix (ns);
				if (prefix == null) {
					if (ns == "http://www.w3.org/XML/1998/namespace")
						prefix = "xml";
					else
						return;
				}
				name = attribute.RefName.Name;
				if (prefix.Length > 0)
					name = prefix + ":" + name;
			}
			if (!names.Add (name))
				return;
			string documentation = GetDocumentation (attribute.Annotation);
			Add (new XmlCompletionData (name, documentation, XmlCompletionData.DataType.XmlAttribute));
		}
開發者ID:Kalnor,項目名稱:monodevelop,代碼行數:23,代碼來源:XmlCompletionDataList.cs

示例14: VisitXmlSchemaAttribute

        public virtual void VisitXmlSchemaAttribute(XmlSchemaAttribute attribute)
        {
            Dispatch(attribute.AttributeSchemaType);

            // why there is no pattern mathing in C# ???

            if(attribute.Parent is XmlSchemaComplexType)
            {
                XmlSchemaComplexType complexType = (XmlSchemaComplexType) attribute.Parent;

                VisitXmlSchemaAttribute(complexType, attribute);
            }
            else if (attribute.Parent is XmlSchemaAttributeGroup)
            {
                XmlSchemaAttributeGroup attributeGroup = (XmlSchemaAttributeGroup)attribute.Parent;

                VisitXmlSchemaAttribute(attributeGroup, attribute);
            }
            else
            {
                Assert.Fail(attribute.Parent.GetType().ToString());
            }
        }
開發者ID:willrawls,項目名稱:arp,代碼行數:23,代碼來源:XsdVisitor.cs

示例15: GetBuildInSchema

 internal static XmlSchema GetBuildInSchema()
 {
     if (builtInSchemaForXmlNS == null)
     {
         XmlSchema schema = new XmlSchema {
             TargetNamespace = "http://www.w3.org/XML/1998/namespace"
         };
         schema.Namespaces.Add("xml", "http://www.w3.org/XML/1998/namespace");
         XmlSchemaAttribute item = new XmlSchemaAttribute {
             Name = "lang",
             SchemaTypeName = new XmlQualifiedName("language", "http://www.w3.org/2001/XMLSchema")
         };
         schema.Items.Add(item);
         XmlSchemaAttribute attribute2 = new XmlSchemaAttribute {
             Name = "base",
             SchemaTypeName = new XmlQualifiedName("anyURI", "http://www.w3.org/2001/XMLSchema")
         };
         schema.Items.Add(attribute2);
         XmlSchemaAttribute attribute3 = new XmlSchemaAttribute {
             Name = "space"
         };
         XmlSchemaSimpleType type = new XmlSchemaSimpleType();
         XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction {
             BaseTypeName = new XmlQualifiedName("NCName", "http://www.w3.org/2001/XMLSchema")
         };
         XmlSchemaEnumerationFacet facet = new XmlSchemaEnumerationFacet {
             Value = "default"
         };
         restriction.Facets.Add(facet);
         XmlSchemaEnumerationFacet facet2 = new XmlSchemaEnumerationFacet {
             Value = "preserve"
         };
         restriction.Facets.Add(facet2);
         type.Content = restriction;
         attribute3.SchemaType = type;
         attribute3.DefaultValue = "preserve";
         schema.Items.Add(attribute3);
         XmlSchemaAttributeGroup group = new XmlSchemaAttributeGroup {
             Name = "specialAttrs"
         };
         XmlSchemaAttribute attribute4 = new XmlSchemaAttribute {
             RefName = new XmlQualifiedName("lang", "http://www.w3.org/XML/1998/namespace")
         };
         group.Attributes.Add(attribute4);
         XmlSchemaAttribute attribute5 = new XmlSchemaAttribute {
             RefName = new XmlQualifiedName("space", "http://www.w3.org/XML/1998/namespace")
         };
         group.Attributes.Add(attribute5);
         XmlSchemaAttribute attribute6 = new XmlSchemaAttribute {
             RefName = new XmlQualifiedName("base", "http://www.w3.org/XML/1998/namespace")
         };
         group.Attributes.Add(attribute6);
         schema.Items.Add(group);
         schema.IsPreprocessed = true;
         schema.CompileSchemaInSet(new NameTable(), null, null);
         Interlocked.CompareExchange<XmlSchema>(ref builtInSchemaForXmlNS, schema, null);
     }
     return builtInSchemaForXmlNS;
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:59,代碼來源:Preprocessor.cs


注:本文中的System.Xml.Schema.XmlSchemaAttribute類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。