无法理解架构验证错误 [英] Can't understand schema validation error

查看:78
本文介绍了无法理解架构验证错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有setting.ValidationType的2.0 XmlReaderSettings对象设置

到ValdationType.Schema来根据模式验证文档。


关注是一个模式片段(名称已更改):

< xsd:element name =" Stuff">

< xsd:complexType>

< xsd:sequence>

< xsd:element ref =" RequiredSimpleThing1" />

< xsd:element ref =" RequiredSimpleThing2" / >

< xsd:element name =" OptionalSimpleThing1" type =" OptionalType"

minOccurs =" 0" />

< xsd:element name =" OptionalSimpleThing2" type =" OptionalType"

minOccurs =" 0" />

< xsd:element name =" ComplexThing" minOccurs =" 0">

< xsd:complexType>

< xsd:sequence maxOccurs =" unbounded">

< xsd:element name =" ChildThing" type =" ChildType" />

< / xsd:sequence>

< / xsd:complexType>

< / xsd:element>

< / xsd:sequence>

< / xsd:complexType>

< / xsd:element>


以下是一个文件片段:

< Stuff>

< RequiredSimpleThing1> 86876< / RequiredSimpleThing1>

< RequiredSimpleThing2> MC< / RequiredSimpleThing2>

< ComplexThing>

<! - 几个ChildThing元素 - >

< / ComplexThing>

< / Stuff>


我从验证器收到的错误是元素''东西''有

无效的子元素''ComplexThing''。可能元素列表

预期:''OptionalSimpleThing1,OptionalSimpleThing2''。"


为什么验证器需要这些可选(minOccurs = 0)元素?

I''m using a 2.0 XmlReaderSettings object with setting.ValidationType set
to ValdationType.Schema to validate a document against a schema.

Following is a schema fragment (names altered):
<xsd:element name="Stuff">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="RequiredSimpleThing1"/>
<xsd:element ref="RequiredSimpleThing2"/>
<xsd:element name="OptionalSimpleThing1" type="OptionalType"
minOccurs="0"/>
<xsd:element name="OptionalSimpleThing2" type="OptionalType"
minOccurs="0"/>
<xsd:element name="ComplexThing" minOccurs="0">
<xsd:complexType>
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="ChildThing" type="ChildType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

Following is a document fragment:
<Stuff>
<RequiredSimpleThing1>86876</RequiredSimpleThing1>
<RequiredSimpleThing2>MC</RequiredSimpleThing2>
<ComplexThing>
<!-- several ChildThing elements -->
</ComplexThing>
</Stuff>

The error I recieve from the validator is "The element ''Stuff'' has
invalid child element ''ComplexThing''. List of possible elements
expected: ''OptionalSimpleThing1, OptionalSimpleThing2''."

Why is the validator requiring these optional (minOccurs = 0) elements?

推荐答案



" Brad Wood" <布拉德利| .wood | @ndsu |埃杜>在消息中写道

news:uz ************** @ TK2MSFTNGP09.phx.gbl ...

"Brad Wood" <bradley|.wood|@ndsu|.edu> wrote in message
news:uz**************@TK2MSFTNGP09.phx.gbl...
我正在使用一个2.0 XmlReaderSettings对象,其中setting.ValidationType设置为ValdationType.Schema以根据模式验证文档。

以下是模式片段(名称已更改):
< xsd :element name =" Stuff">
< xsd:complexType>
< xsd:sequence>
< xsd:element ref =" RequiredSimpleThing1" />
< xsd:element ref =" RequiredSimpleThing2" />
< xsd:element name =" OptionalSimpleThing1" type =" OptionalType"
minOccurs =" 0" />
< xsd:element name =" OptionalSimpleThing2" type =" OptionalType"
minOccurs =" 0" />
< xsd:element name =" ComplexThing" minOccurs =" 0">
< xsd:complexType>
< xsd:sequence maxOccurs =" unbounded">
< xsd:element name =" ChildThing" type =" ChildType" />
< / xsd:sequence>
< / xsd:complexType>
< / xsd:element>
< / xsd :sequence>
< / xsd:complexType>
< / xsd:element>

以下是一个文档片段:
< Stuff>
< RequiredSimpleThing1> 86876< / RequiredSimpleThing1>
< RequiredSimpleThing2> MC< / RequiredSimpleThing2>
< ComplexThing>
<! - 几个ChildThing元素 - >
< / ComplexThing>
< / Stuff>

我从验证器收到的错误是元素''Stuff''具有无效的
子元素'' ComplexThing ''。预期可能元素列表:
''OptionalSimpleThing1,OptionalSimpleThing2''。"

为什么验证器需要这些可选(minOccurs = 0)元素?
I''m using a 2.0 XmlReaderSettings object with setting.ValidationType set
to ValdationType.Schema to validate a document against a schema.

Following is a schema fragment (names altered):
<xsd:element name="Stuff">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="RequiredSimpleThing1"/>
<xsd:element ref="RequiredSimpleThing2"/>
<xsd:element name="OptionalSimpleThing1" type="OptionalType"
minOccurs="0"/>
<xsd:element name="OptionalSimpleThing2" type="OptionalType"
minOccurs="0"/>
<xsd:element name="ComplexThing" minOccurs="0">
<xsd:complexType>
<xsd:sequence maxOccurs="unbounded">
<xsd:element name="ChildThing" type="ChildType"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

Following is a document fragment:
<Stuff>
<RequiredSimpleThing1>86876</RequiredSimpleThing1>
<RequiredSimpleThing2>MC</RequiredSimpleThing2>
<ComplexThing>
<!-- several ChildThing elements -->
</ComplexThing>
</Stuff>

The error I recieve from the validator is "The element ''Stuff'' has invalid
child element ''ComplexThing''. List of possible elements expected:
''OptionalSimpleThing1, OptionalSimpleThing2''."

Why is the validator requiring these optional (minOccurs = 0) elements?




对我来说还行。也许你的帖子过于简单了。

发布一些真正的文件(如有必要,删除并更改名称),产生错误。



Looks OK to me. Perhaps you have oversimplified in your post.
Post some real files (cut down and names changed if necessary) that produce
the error.


我是XSD的新手,但无论如何我都去了,说出来并表现出来是这样的。

a傻瓜:-)


01)如果元素的顺序不重要,我使用xs:all而不是xs:sequence。

重要。 (不太相关)

02)你有xsd:到处都是新闻组错字?

03)" xs:sequence maxOccurs",不应该是maxOccures不在xs中;序列

但在xs:元素中在它下面?


Pete
I am new to XSD, but here I go anyway, speaking up and showing myself to be
a fool :-)

01) I use xs:all rather than xs:sequence if the order of the elements is not
important. (Not really relevant)
02) You have "xsd:" everywhere, a newsgroup typo?
03) "xs:sequence maxOccurs", shouldn''t the maxOccures not be in xs;sequence
but in the xs:element beneath it?

Pete




" Peter Morris [Droopy eyes software]" < pete @ droopyeyes [dot] comREMOVETHIS>

在消息新闻中写道:%2 **************** @ TK2MSFTNGP11.phx.gbl ...

"Peter Morris [Droopy eyes software]" <pete@droopyeyes[dot]comREMOVETHIS>
wrote in message news:%2****************@TK2MSFTNGP11.phx.gbl...
我是XSD的新手,不管怎么说我走了,说出来并表明自己是个傻瓜:-)

01)我用的是xs:所有而不是xs:序列,如果元素的顺序不重要。 (不太相关)
I am new to XSD, but here I go anyway, speaking up and showing myself to be
a fool :-)

01) I use xs:all rather than xs:sequence if the order of the elements is
not important. (Not really relevant)




有充分理由不使用全部。


是 - 在抽象建模中条款是正确的,但在实践中它绝不是好主意。



There are good reasons not to use "all".

Yes - in abstract modelling terms it is correct but in practice it is never
a good idea.


这篇关于无法理解架构验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆