简体   繁体   中英

How to get the value of abstract property in xsd file

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.

看起来您在寻找XmlSchemaComplexType.IsAbstract属性

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM