我觉得一个标签既然有相同的tagname,就应该有相同的结果.
既然你的不同参数有不同的枚举,那么你的参数应该是固定的吧,所以你的xml可以考虑换一种设计方式
<book>
<params>
<bookname>xxx</bookname>
<vendor>xxx</bookname>
<contry>xxx</bookname>
</params>
</book>
既然你的不同参数有不同的枚举,那么你的参数应该是固定的吧,所以你的xml可以考虑换一种设计方式
<book>
<params>
<bookname>xxx</bookname>
<vendor>xxx</bookname>
<contry>xxx</bookname>
</params>
</book>
目前的Schema能达到你的要求吗?反正我以前是没这么做过……
我目前提供的参考解决方案是:
1、写个迁就一点的Schema
2、更严格的有效性验证在程序代码中实现我给写了一个简单的Schema,如下:<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="book">
<xs:complexType>
<xs:sequence>
<xs:element name="param" maxOccurs="3">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
所以,还是不行哈,但是还是谢谢楼上了