我用下面一个例子来解释如何定义XSD以及如何使用它来验证
1. 首先来看一下我们的数据文件
<?xml version="1.0" encoding="utf-8" ?>
<Order>
<OrderID>10248</OrderID>
<OrderDate>2009-01-01</OrderDate>
<Details>
<OrderItem>
<ItemNumber>1</ItemNumber>
<ProductID>1</ProductID>
<Quantity>2</Quantity>
<UnitPrice>20</UnitPrice>
</OrderItem>
<OrderItem>
<ItemNumber>1</ItemNumber>
<ProductID>1</ProductID>
<Quantity>2</Quantity>
<UnitPrice>20</UnitPrice>
</OrderItem>
<OrderItem>
<ItemNumber>1</ItemNumber>
<ProductID>1</ProductID>
<Quantity>2</Quantity>
<UnitPrice>20</UnitPrice>
</OrderItem>
<OrderItem>
<ItemNumber>1</ItemNumber>
<ProductID>1</ProductID>
<Quantity>2</Quantity>
<UnitPrice>20</UnitPrice>
</OrderItem>
</Details>
</Order>