美好的一天。
在我的项目中。
我想获得抽象属性值。 在调试期间。我可以发现“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 ...
}
}
}
}
}
谢谢。