tags:

views:

33

answers:

1

Hello.

Good day.

In my project.

I want to get the abstract property value. During debuging. I can find the "elementDecl.isAbstract" is "true". But i don't know how to code.

 <xsd:complexType name="Step.type" abstract="true"/>

My code to check the abstract method.

if (complexSequence == null && complexSchemaType.AttributeUses.Count == 0)

Could you help me to imporve the method with something like elementDecl.isAbstract ?

THANKS.

[Updated] my code below

public void AbstractTypeParse()
{

        using (TextWriter writer = File.CreateText("D:\\learning\\TMP\\foo.cs"))
        {
            // Add the customer schema to a new XmlSchemaSet and compile it.
            // Any schema validation warnings and errors encountered reading or 
            // compiling the schema are handled by the ValidationEventHandler delegate.
            XmlSchemaSet schemaSet = new XmlSchemaSet();
            schemaSet.ValidationEventHandler += new ValidationEventHandler(ValidationCallback);
            schemaSet.Add("http://www.w3.org/2001/XMLSchema", "D:\\learning\\TMP\\tmp.xsd");
            schemaSet.Compile();

            // Retrieve the compiled XmlSchema object from the XmlSchemaSet
            // by iterating over the Schemas property.
            XmlSchema customerSchema = null;
            foreach (XmlSchema schema in schemaSet.Schemas())
            {
                customerSchema = schema;
            }

            foreach (XmlSchemaType SchemaType in customerSchema.SchemaTypes.Values)
            {
                // handle ComplexChildElement is simple type here
                if (SchemaType.BaseXmlSchemaType.ToString() == "System.Xml.Schema.XmlSchemaComplexType")
                {
                    // convert SchemaType to Complex SchemaType
                    XmlSchemaComplexType complexSchemaType = SchemaType as XmlSchemaComplexType;

                    XmlSchemaSequence complexSequence = complexSchemaType.ContentTypeParticle as XmlSchemaSequence;

                    if (complexSequence == null && complexSchemaType.AttributeUses.Count == 0)
                    {
                    // Instered some code here ...
                    }

                }
           }
      }
}

Thank you.

+1  A: 

Looks like you're looking for XmlSchemaComplexType.IsAbstract property

Pavel Minaev
It works. Thanks.
Nano HE