Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will only be able to tell it that attr1 is required, and attr2 and attr3 are optional. There is no way that I know off defining in a XSD schema (for XML 1.0) that you can't have both attr2 and attr3. You would have to have something validate it afterwards to check for that combination.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-16"?&gt; &lt;xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; &lt;xs:element name="root"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element maxOccurs="unbounded" name="node"&gt; &lt;xs:complexType&gt; &lt;xs:attribute name="attr1" type="xs:int" use="required" /&gt; &lt;xs:attribute name="attr2" type="xs:int" use="optional" /&gt; &lt;xs:attribute name="attr3" type="xs:int" use="optional" /&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:sequence&gt; &lt;/xs:complexType&gt; &lt;/xs:element&gt; &lt;/xs:schema&gt; </code></pre> <p>EDIT: I came across another thread where someone wanted some complex validation like yours and a link was provided in one of the comments too an article talking about <a href="http://www.w3.org/wiki/Co-occurrence_constraints" rel="nofollow">Co-occurrence constraints</a> which is what you are after and was implement for XML version 1.1. I also come accross this article <a href="http://www.ibm.com/developerworks/library/x-xml11pt2/" rel="nofollow">XML Schema 1.1, Part 2: An introduction to XML Schema 1.1</a> that went into details. Unfortunately XML 1.1 does not seem to be widely supported.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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