Как получить значение абстрактного свойства в файле xsd - PullRequest
0 голосов
/ 21 декабря 2009

Добрый день.

В моем проекте.

Я хочу получить абстрактное значение свойства. Во время отладки. Я могу найти, что "elementDecl.isAbstract" равен "true". Но я не знаю, как кодировать.

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

Мой код для проверки абстрактного метода.

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

Не могли бы вы помочь мне улучшить метод чем-то вроде elementDecl.isAbstract ?

СПАСИБО.

[Обновлено] мой код ниже

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 ...
                    }

                }
           }
      }
}

Спасибо.

1 Ответ

1 голос
/ 24 декабря 2009

Похоже, вы ищете XmlSchemaComplexType.IsAbstract свойство

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...