0

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?

Community
  • 1
  • 1
mostafa.S
  • 1,452
  • 4
  • 16
  • 27
  • 2
    Among the Stack Overflow questions which address this issue are http://stackoverflow.com/questions/15517396/ http://stackoverflow.com/questions/12600635/ http://stackoverflow.com/questions/9200365/ http://stackoverflow.com/questions/13634243/ http://stackoverflow.com/questions/19923116/ http://stackoverflow.com/questions/11743510/ http://stackoverflow.com/questions/12956369/ http://stackoverflow.com/questions/17856049/ http://stackoverflow.com/questions/6888101/ http://stackoverflow.com/questions/14592378/ http://stackoverflow.com/questions/4081789/ http://stackoverflow.com/questions/15177678/ – C. M. Sperberg-McQueen Jun 12 '14 at 01:53
  • This question addresses a situation very similar to yours and provides two different solutions using XSD 1.1: http://stackoverflow.com/questions/23545674/xml-validation-different-child-tags-based-on-attribute-value/23564251#23564251 – helderdarocha Jun 12 '14 at 02:24
  • Okay it seems and schema 1.1 is my answer, but Eclipse Kepler Service Release 1, doesn't recognize the tag and marks it as an error! what to do about that? – mostafa.S Jun 17 '14 at 04:59
  • @C.M.Sperberg-McQueen If I could I'd "favorite" your comment. – lexicore Oct 18 '14 at 20:37

0 Answers0