如何在xsd文件中获取抽象属性的值
问题描述:
美好的一天。如何在xsd文件中获取抽象属性的值
在我的项目中。
我想获取抽象属性值。 在调试过程中。我可以找到“elementDecl.isAbstract”是“true”。 但我不知道如何编码。
<xsd:complexType name="Step.type" abstract="true"/>
我的代码来检查抽象方法。
if (complexSequence == null && complexSchemaType.AttributeUses.Count == 0)
你能帮我喜欢的东西elementDecl.isAbstract ?
THANKS imporve的方法。
下面
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 ...
}
}
}
}
}
[更新] 我的代码谢谢。
它的工作原理。谢谢。 – 2009-12-24 04:52:01