使用在 XML 模式的复杂类型中?
我定义了以下 XML complexType
:
<xs:complexType name="loss">
<xs:all>
<xs:element name="lossCause" type="xs:string"/>
<xs:element name="lossDate" type="xs:dateTime"/>
<xs:element name="lossDescription" type="xs:string"/>
<xs:element name="lossLocation" type="address" minOccurs="0"/>
<xs:element name="lossTime" type="xs:string" minOccurs="0"/>
<xs:element name="officials" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="official" type="official" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="incidentOnly" type="xs:boolean" use="required"/>
<xs:attribute name="lawsuit" type="xs:boolean" use="required"/>
</xs:complexType>
并且:
<xs:complexType name="propLoss">
<xs:complexContent>
<xs:extension base="loss">
<xs:all>
<xs:element name="damageDescription" type="xs:string"/>
<xs:element name="property" type="property"/>
<xs:element name="responsibleParty" type="contact" minOccurs="0"/>
</xs:all>
<xs:attribute name="businessOperational" type="xs:boolean" use="required"/>
<xs:attribute name="propertyLivable" type="xs:boolean" use="required"/>
<xs:attribute name="weatherRelated" type="xs:boolean" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
但是,在验证时,我收到一条错误,指出 loss 中不允许使用
all
模型组complexType
及其扩展 propLoss
定义。我做错了什么?
谢谢!
I have the following XML complexType
s defined:
<xs:complexType name="loss">
<xs:all>
<xs:element name="lossCause" type="xs:string"/>
<xs:element name="lossDate" type="xs:dateTime"/>
<xs:element name="lossDescription" type="xs:string"/>
<xs:element name="lossLocation" type="address" minOccurs="0"/>
<xs:element name="lossTime" type="xs:string" minOccurs="0"/>
<xs:element name="officials" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="official" type="official" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="incidentOnly" type="xs:boolean" use="required"/>
<xs:attribute name="lawsuit" type="xs:boolean" use="required"/>
</xs:complexType>
and:
<xs:complexType name="propLoss">
<xs:complexContent>
<xs:extension base="loss">
<xs:all>
<xs:element name="damageDescription" type="xs:string"/>
<xs:element name="property" type="property"/>
<xs:element name="responsibleParty" type="contact" minOccurs="0"/>
</xs:all>
<xs:attribute name="businessOperational" type="xs:boolean" use="required"/>
<xs:attribute name="propertyLivable" type="xs:boolean" use="required"/>
<xs:attribute name="weatherRelated" type="xs:boolean" use="required"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
However, upon validation, I get an error stating that the all
model group isn't allowed within the loss
complexType
nor its extension propLoss
definition. What is it that I'm doing wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
propLoss
的一个问题是您无法在 XML Schema (1.0) 中扩展all
组。从规格来看:不确定
loss
的问题是什么,除非它因propLoss
错误而造成附带损害。A problem with
propLoss
is that you can't extend anall
group in XML Schema (1.0). From the spec:Not sure what the problem with
loss
is unless it collateral damage from thepropLoss
error.请注意,在 XSD 1.1 中,
all
组可以按照此处所示的方式进行扩展,这意味着任一all
组中提到的所有子组都必须存在于任何组中。命令。 (也就是说,所有组 1 和所有组 2 通过其子组的串联合并为一个全组。)Note that in XSD 1.1
all
groups can be extended in the way shown here, with the meaning being that all of the children mentioned in eitherall
-group must be present in any order. (That is, all-group 1 and all-group 2 get merged together into a single all-group with the concatenation of their children.)