【发布时间】:2015-08-20 05:17:27
【问题描述】:
我得到了下一个 XML:
<!-- language: xml -->
<Message name="Msg1" type="SIMPLE">
<Doc> message to send </Doc>
<Parameters>
<Parameter name="param1" type="byte" filter="2" mask="On">
<Fields>
<Field encode="hex">
<Values>
<Value name="INDICATOR" id="0"/>
</Values>
</Field>
</Fields>
</Parameter>
<Parameter name="param2" type="byte" filter="3" mask="On"/>
<Parameter name="param3" type="byte"/>
</Parameters>
</Message>
我的 XSD 文件就是这个:
<xs:element name="Message" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="Doc" minOccurs="0"/>
<xs:element name="Parameters" minOccurs="0">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Parameter" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="Doc" minOccurs="0"/>
<xs:element name="Fields" minOccurs="0">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Field" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="Doc" minOccurs="0"/>
<xs:element name="Values" minOccurs="0">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element ref="Doc" minOccurs="0"/>
<xs:element name="Value" minOccurs="1" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="name" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>Name of the value</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="id" type="xs:string" use="required">
<xs:annotation>
<xs:documentation>The value</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:choice>
<xs:attribute name="encode" type="xs:string" default="hex">
<xs:annotation>
<xs:documentation>encoding</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="unique_filed_name">
<xs:selector xpath="Field"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
</xs:choice>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="type" type="xs:string"/>
<xs:attribute name="filter" type="xs:string"/>
<xs:attribute name="mask" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
<xs:unique name="unique_parameter_name">
<xs:selector xpath="Parameter"/>
<xs:field xpath="@name"/>
</xs:unique>
</xs:element>
</xs:choice>
<xs:attribute name="name">
<xs:annotation>
<xs:documentation>Unique</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="MessageTypes" use="required">
<xs:annotation>
<xs:documentation>Select a valid type</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
我毫无意义地收到了这个错误,因为我在 XSD 中添加了过滤器:
元素“参数”,属性“过滤器”:属性“过滤器”不是 允许。
谁能帮我解释一下为什么我遇到了这个似乎很难解决的错误?
【问题讨论】:
-
投反对票,因为当问题(部分)得到回答时您没有跟进。您似乎有提出问题但不承认答案的历史。