I am trying to make a schema where the type of an element is determined by the value of a parent's attribute. In particular, want I want to do is this
<argument name="foo" type="float">5.6</argument>
where the value of the argument should be enforced to conform with a floating point value. So that the type of the value element is of the type defined by the attribute of the argument element.
Now, I found an older post on the topic where it was stated that this cannot be done in XML-Schema 1.0.
So my question is; Is there a recommended alternate way to do it? The closest I can think of is allowing something like
<argument name="foo">
<float>5.6</float>
</argument>
Letting argument contain an element of the type type and then let float be derived from type.
Depends what you mean by "an alternate way". You can change your document design (e.g. to use xsi:type), you can use a different validation methodology (e.g. RelaxNG or Schematron), or you can move to XSD 1.1.