System.Xml.Schema.XsdBuilder.AddAttribute C# (CSharp) Method

AddAttribute() private method

private AddAttribute ( XmlSchemaObject value ) : void
value XmlSchemaObject
return void
        private void AddAttribute(XmlSchemaObject value)
        {
            switch (this.ParentElement)
            {
                case SchemaNames.Token.XsdComplexType:
                    if (_complexType.ContentModel != null)
                    {
                        SendValidationEvent(SR.Sch_AttributeMutuallyExclusive, "attribute");
                    }
                    if (_complexType.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _complexType.Attributes.Add(value);
                    break;
                case SchemaNames.Token.XsdSimpleContentRestriction:
                    if (_simpleContentRestriction.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _simpleContentRestriction.Attributes.Add(value);
                    break;
                case SchemaNames.Token.XsdSimpleContentExtension:
                    if (_simpleContentExtension.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _simpleContentExtension.Attributes.Add(value);
                    break;
                case SchemaNames.Token.XsdComplexContentExtension:
                    if (_complexContentExtension.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _complexContentExtension.Attributes.Add(value);
                    break;
                case SchemaNames.Token.XsdComplexContentRestriction:
                    if (_complexContentRestriction.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _complexContentRestriction.Attributes.Add(value);
                    break;
                case SchemaNames.Token.xsdAttributeGroup:
                    if (_attributeGroup.AnyAttribute != null)
                    {
                        SendValidationEvent(SR.Sch_AnyAttributeLastChild, null);
                    }
                    _attributeGroup.Attributes.Add(value);
                    break;
                default:
                    Debug.Assert(false);
                    break;
            }
        }

Usage Example

Example #1
0
 /*
     <attribute 
       form = qualified | unqualified 
       id = ID 
       name = NCName 
       ref = QName 
       type = QName 
       use = prohibited | optional | required | default | fixed : optional
       value = string 
       {any attributes with non-schema namespace . . .}>
       Content: (annotation? , (simpleType?))
     </attribute>
 */
 private static void InitAttribute(XsdBuilder builder, string value) {
     builder.xso = builder.attribute = new XmlSchemaAttribute();
     if (builder.ParentElement == SchemaNames.Token.XsdSchema)
         builder.schema.Items.Add(builder.attribute);
     else 
         builder.AddAttribute(builder.attribute);
     builder.canIncludeImport = false;  // disable import and include elements in schema
 }
All Usage Examples Of System.Xml.Schema.XsdBuilder::AddAttribute
XsdBuilder