Hello,
I have an XSD question to see whether or not it is possible to write schema rules for an .xsd file for the following scenario:
I have an element <parameter>. Here are my desired rules:
If it is used inside a <function> element, then it MUST have one and only one <type> element inside of it.
However, it if is used inside a <macro> element, then it cannot have ANY <type> element inside of it.
In other words, observe the following two XML examples:
<function name="sqrt">
<parameter name="x">
<type name="float"/>
</parameter>
<return value="float"/>
</function>
vs.
<macro name="SQRT">
<parameter name="X"/>
<expression value="sqrt(X)"/>
</macro>
As you can see, in the <function> case, the <parameter> element MUST have a <type> given inside of it. However, in the <macro> case, it must NOT have a <type>. That is, the following XML statement should fail:
<macro name="SQRT">
<parameter name="X">
<type name="int"/>
</parameter>
<expression value="sqrt(X)"/>
</macro>
Is there any way to specify in the XSD schema doc rules that basically say "if using <parameter> inside a <function>, then you must have one and only one <type> nested inside of it; however, if using <parameter> inside a <macro>, then you can have NO elements nested inside of it." In other words, I want the rules as to what can and cannot be nested inside an element to vary, based upon who its parent it.
I hope I have explained the question succinctly enough, and I thank you for any and all responses.
--K. Suffecool
I have an XSD question to see whether or not it is possible to write schema rules for an .xsd file for the following scenario:
I have an element <parameter>. Here are my desired rules:
If it is used inside a <function> element, then it MUST have one and only one <type> element inside of it.
However, it if is used inside a <macro> element, then it cannot have ANY <type> element inside of it.
In other words, observe the following two XML examples:
<function name="sqrt">
<parameter name="x">
<type name="float"/>
</parameter>
<return value="float"/>
</function>
vs.
<macro name="SQRT">
<parameter name="X"/>
<expression value="sqrt(X)"/>
</macro>
As you can see, in the <function> case, the <parameter> element MUST have a <type> given inside of it. However, in the <macro> case, it must NOT have a <type>. That is, the following XML statement should fail:
<macro name="SQRT">
<parameter name="X">
<type name="int"/>
</parameter>
<expression value="sqrt(X)"/>
</macro>
Is there any way to specify in the XSD schema doc rules that basically say "if using <parameter> inside a <function>, then you must have one and only one <type> nested inside of it; however, if using <parameter> inside a <macro>, then you can have NO elements nested inside of it." In other words, I want the rules as to what can and cannot be nested inside an element to vary, based upon who its parent it.
I hope I have explained the question succinctly enough, and I thank you for any and all responses.
--K. Suffecool