Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>key</code> element is not supposed to go inside the <code>sequence</code> element. Instead, you put it as a child of the <code>xs:element</code> that defines <code>ReferralCollection</code>. The <code>selector</code> and <code>field</code> are child elements of the <code>key</code> element that define what is supposed to be unique. Both are XPath expressions. The <code>selector</code> value sets up the XPath context, and the <code>field</code> elements (there can be more than one) define the combination of values that are supposed to be unique. So in your case, the <code>key</code> element might look something like this:</p> <pre><code>&lt;xs:key name="URL"&gt; &lt;xs:selector xpath="."/&gt; &lt;xs:field xpath="rd:keyword"/&gt; &lt;/xs:key&gt; </code></pre> <p>The <code>selector</code> here selects the element itself, that is, <code>ReferralCollection</code>. Then, in that context, the <code>field</code> element denotes the values of the <code>keyword</code> elements, which are thus constrained to be unique. The value of an element in XPath is its text content.</p> <p>I haven't done much with <code>key</code> elements (or XML Schema in general), so some details above might not be correct, but the basic idea is what I explained, so it should be easy to fix any mistakes I made. Oh, also note that I used the <code>rd</code> prefix for your <code>READOO</code> namespace; in my experience using explicit prefixes is always best when dealing with XPath, so you need the appropriate <code>xmlns:rd</code> attribute in your schema to make this work.</p> <p><strong>EDIT:</strong> So it seems you want something like this:</p> <pre><code>&lt;xs:element name="ReferralCollection"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="URL" maxOccurs="unbounded"&gt; &lt;xs:complexType&gt; &lt;xs:sequence&gt; &lt;xs:element name="stem" type="xsd:string"/&gt; &lt;xs:element name="keyword" maxOccurs="unbounded"&gt; ... &lt;/xs:element&gt; ... &lt;/xs:complexType&gt; &lt;xs:key name="URL"&gt; &lt;xs:selector xpath="./URL"/&gt; &lt;xs:field xpath="stem"/&gt; &lt;/xs:key&gt; &lt;/xs:element&gt; </code></pre> <p>Is this closer to what you meant? It has <code>URL</code> elements, one or more, each containing a <code>stem</code> element followed by one or more <code>keyword</code> elements. The <code>key</code> constraint should make the contents of the <code>stem</code> elements unique.</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