日期:2014-05-18  浏览次数:20707 次

求一个验证xml的schema的写法
XML code

<person>
    <personinfo>
        <name></name>
        <father>
            <personinfo>
                <name></name>
                <father>
                    ……
                </father>
            </personinfo>
        </father>
    </personinfo>
</person>



就是想用一个schema验证子孙N代的校验,看了相关资料,嵌套没搞明白。呵呵,希望可以给一个完善一点的xsd,有相关的说明更好了。

------解决方案--------------------
xml中一個元素属性又有值的schema的驗證寫法.

 如下:

  例如:下面的元素的寫法:

<price days="12">5500</price>

schema的驗證寫法:

     <xs:element name="price" maxOccurs="2">
<xs:complexType mixed="true">
<xs:attribute name="days">
<xs:simpleType>
<xs:restriction base="xs:integer"></xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>