Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>My reading of the <a href="http://www.w3.org/TR/xmlschema-1/" rel="nofollow noreferrer">XML schema standard</a> says that you are probably safe. You just define non-consecutive elements with the same name in your schema, to reflect the XML as it will (or can be) generated. As long as all "error" instances are <em>always</em> separated by other elements and not consecutive, this shouldn't be a problem. For example, something like:</p> <pre> &lt;xs:element name="data"> &lt;xs:complexType> &lt;xs:sequence> &lt;xs:element name="summary" minOccurs="1" maxOccurs="1" type="xs:string" /> &lt;xs:element ref="error" minOccurs="1" maxOccurs="1" /> &lt;xs:element name="details" minOccurs="1" maxOccurs="1" type="detailsType" /> &lt;xs:element ref="error" minOccurs="1" maxOccurs="1" /> &lt;xs:element name="z" minOccurs="0" maxOccurs="1" type="xs:string" /> &lt;/xs:sequence> &lt;/xs:complexType> &lt;/xs:element> &lt;xs:element name="error" type="xs:string"/> &lt;xs:complexType name="detailsType"> .... &lt;/xs:complexType> </pre> <p>If details has minOccurs="0" and the first "error" above has a maxOccurs > 1, then you fail the Unique Particle Attribution rule, because validation cannot verify, if you have two error elements in a row, which instance of "error" in the schema they belong to. However, as long as each instance of "error" can be uniquely identified in the schema, due to good use of "minOccurs" and "maxOccurs" for the error elements and for intervening elements, then you are good.</p> <p>You can even have consecutive instances of "error" as long as the schema validator can always unambiguously figure out which instance is being referred to by using minOccurs and maxOccurs (for example).</p> <p>Think about xhtml, in which the elements may occur in any order, with arbitrary repetition.</p> <p>EDIT: Updated to reflect edits in original question.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload