简体   繁体   中英

How to restrict what children tags should be by using attribute?

I have an snippet XML like this:

....
<cell type='1'>
    <A>Some text</A>
</cell>
<cell type='2'>
    <B>Some text</B>
</cell>
....

How to write a schema that enforces element A to be a child of 'cell' only when 'type' attribute is 1 (B if 2) ?.

Thanks!

sorry but I think the current XSD doesn't allow this.

the only way to define choice or alternative is by using the xsd:choice tag. this only specify which elements to choose from and the cardinality (maximum and minimum occurrence) of these, but not on some conditions.

so its only about the which and how much elements but surely not on which conditions to choose from

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