Invalid Constraint Value

ぐ巨炮叔叔 提交于 2019-12-05 17:33:00

The XSD snippets are valid, so the error you're getting makes no sense. I believe it is rather a bug in your WMB software.

What version of WMB are you using?

Since you seem to be able to play with the XSD, it would also help with troubleshooting if instead of removing the default attribute, try to rewrite the pattern from one with the value of "0|1", into two separate patterns, one with a value of "0", and another with the value of "1". I've seen before with other products from the same vendor where patterns associated with xsd:boolean fail miserably.

UPDATE: Since posting this, I've ran myself into this and other similar scenarios, and realized that schema processors behave differently while validating what seems to be basically the same thing: a schema that correct according to the spec, yet practically it describes an impossibility. And this is where things get interesting as to what correct is.

This case is a bit more subtle maybe, since it involves getting this and this right; basically if a default kicks in, it'll use the canonical representation of the associated value (not the string in the default value!). Since 1 means True for a boolean, the canonical representation of that is the string true which now obviously doesn't match the pattern (which deals with the lexical representation - string basically) 0|1 which in turn makes these two incompatible. Considering PSVI, an XML processor that is XSD aware cannot create valid XML when applying the default. This is what the error message says.

To show other imposibility that is not flagged by any XSD processor I am typically using, consider this particular snippet:

<xsd:complexType name="Test">
    <xsd:sequence>
        <xsd:element name="Impossible" type="Test"/>
    </xsd:sequence>
</xsd:complexType>
<xsd:element name="Test" type="Test"/>

It is impossible to create a valid XML out of this XSD, just as having a default="1" and attribute missing in your case (of pattern restricted to 0 and 1).

To me, both scenarios are somewhat similar to a code compiler catching (at compile time) a divide by zero condition - where it can.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!