1

Found this interesting post: How to make type depend on attribute value using Conditional Type Assignment

However, can conditional type assignment depend on a node value rather than an attribute?

<listOfA>
  <a>
    <type>1</type>
    <name></name>
    <surname></surname>
  </a>
  <a>
    <type>2</type>
    <name></name>
    <id></id>
  </a>
</listOfA>

I'd like to make an XSD, so that if the value of node "type" is 1, the name and surname elements must be present, and when it's 2, name and id must be there...

Note: I know using an attribute would be better here, but I need to write an XSD for an legacy XML format I cannot change...

jpo38
  • 20,821
  • 10
  • 70
  • 151
  • No, conditional type assignment must be based upon an attribute, not an element, value. See duplicate link for alternative approaches. – kjhughes Aug 12 '17 at 04:26
  • @kjhughes: Thank you. I saw you trusted all XSD posts on this site and was expecting an answer from you! ;-) – jpo38 Aug 12 '17 at 13:39

0 Answers0