开发者

XSD Restrictions based on target xml elements

开发者 https://www.devze.com 2022-12-24 23:26 出处:网络
Is it possible in xsd to create restriction based on elements of some type in target (processed) document?

Is it possible in xsd to create restriction based on elements of some type in target (processed) document?

For example I have XML like this:

<Pets>
 <Pet name="Murka" />开发者_如何学Python
 <Pet name="Browko" />
 <Pet name="Tuzik" />
</Pets>

<Children>
 <Child name="Petruk" favoritePet="Browko" />
</Children>

so what I want to restrict the attribute "favoritePet" of element "Child" based on existing "Pet" elements. How can I do this?


No, with the current XSD 1.0 specifications, you cannot do these kind of dependencies.

Should XSD 1.1 become a reality, then yes, that would support these kind of "assertions" - but I don't think anyone supports and uses XSD 1.1 at this time.


I found that "keyref" is an answer to my question :) It is solved now. Here is the resource.

0

精彩评论

暂无评论...
验证码 换一张
取 消