感谢大家提出建议并在需要时提供帮助。
昨天我试图在 asp.net 4.0 中开发和 web 应用程序,我需要从 xml 解析数据并将其保存在数据库中。但在此之前,我还必须对其进行验证。
我尝试使用 .net 提供的工具 xsd.exe 生成架构文件,但我不知道它如何知道标记哪些节点或属性是强制性的?
就像在我的 xml 中一样,以下项目是强制性的
Root node <Market>
<Login> and its sub element
<ProductType> and its <ProductTypeID/>
The attribute DML is mandatory but should have only 3 values NONE, PUT or MODIFY
<ProductType> may or may not have <ProductItem>
If <ProductItem> is present then it should have <ProductItemID>
<ProductItem> may or may not have <Brand>
If <Brand> is present then it should have <BrandID>
下面是我的xml
<?xml version="1.0" encoding="utf-8" ?>
<Market>
<Login>
<LoginId />
<Password />
</Login>
<ProductType DML="NONE">
<ProductTypeID/>
<Name/>
<Detail/>
<ProductItem DML="PUT">
<ProductItemID/>
<Name/>
<Detail/>
<Brand DML="PUT">
<BrandID/>
<Name/>
<Detail/>
</Brand>
<Brand DML="MODIFY">
<BrandID/>
<Name/>
<Detail/>
</Brand>
</ProductItem>
<ProductItem DML="MODIFY">
<ProductItemID/>
<Name/>
<Detail/>
</ProductItem>
</ProductType>
</Market>
我应该如何以及在哪里指定所有强制和可选参数,以便根据要求生成我的 xsd。
谢谢,
M。