XSD - how to specify element structure depending on its attribute value?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 00:40:34

问题


I have an XML which I validate by an XSD schema. inside the XML, I have the element . depending on value of stereotype attribute, I want to have different inner structure for the element; take following two variations:

1)

<step stereotype="checkerStep" taskType="tableChecker">
   <tableName>employee</tableName>
</step>

2)

<step stereotype="branchStep">
   <branchName>whichStep</branchName>
</step>

as you can see, if stereotype is "checkerStep", as taskType attribute would be necessary, and a tableName inner element is expected. on the other hand, if stereotype is "branchStep", no attribute should be included and a branchName inner element is expected.

I googled my problem and found some answer which suggests using choice indicator, however as it's admitted in the comments under the answer , it's doesn't really address the question; because choice indicator doesn't allow elements with the same name in the same scope!

then, what do I do?

来源:https://stackoverflow.com/questions/24162153/xsd-how-to-specify-element-structure-depending-on-its-attribute-value

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