简体   繁体   中英

XSD Restrictions based on target xml elements

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" />
 <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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM