Q:

XPath Unqiue Element Not Working

Here is my schema:
<? xml version="1.0" encoding="utf-8"? >
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="chessGame">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="pawns" type="pawns" minOccurs="1" maxOccurs="1"/>
        <xs:element name="knights" type="knights" minOccurs="1" maxOccurs="1"/>
        <xs:element name="kings" type="kings" minOccurs="1" maxOccurs="1"/>
        <xs:element name="queens" type="queens" minOccurs="1" maxOccurs="1"/>
        <xs:element name="rooks" type="rooks" minOccurs="1" maxOccurs="1"/>
        <xs:element name="bishops" type="bishops" minOccurs="1" maxOccurs="1"/>
      </xs:sequence>
      <xs:attribute name="dateTime" type="xs:dateTime" use="required"/>
    </xs:complexType>
    <xs:unique name="uniquePosition">
      <xs:selector xpath="chessgame"/>
      <xs:field xpath="@position"/>
    </xs:unique>
  </xs:element>

  <xs:complexType name="pawns">
    <xs:sequence>
      <xs:element name="whitePawn" type="chessPiece" minOccurs="8" maxOccurs="8"/>
      <xs:element name="blackPawn" type="chessPiece" minOccurs="8" maxOccurs="8"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="knights">
    <xs:sequence>
      <xs:element name="whiteKnight" type="chessPiece" minOccurs="2" maxOccurs="2"/>
      <xs:element name="blackKnight" type="chessPiece" minOccurs="2" maxOccurs="2"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="kings">
    <xs:sequence>
      <xs:element name="whiteKing" type="chessPiece" minOccurs="1" maxOccurs="1"/>
      <xs:element name="blackKing" type="chessPiece" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="queens">
    <xs:sequence>
      <xs:element name="whiteQueen" type="chessPiece" minOccurs="1" maxOccurs="1"/>
      <xs:element name="blackQueen" type="chessPiece" minOccurs="1" maxOccurs="1"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="bishops">
    <xs:sequence>
      <xs:element name="whiteBishop" type="chessPiece" minOccurs="2" maxOccurs="2"/>
      <xs:element name="blackBishop" type="chessPiece" minOccurs="2" maxOccurs="2"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="rooks">
    <xs:sequence>
      <xs:element name="whiteRook" type="chessPiece" minOccurs="2" maxOccurs="2"/>
      <xs:element name="blackRook" type="chessPiece" minOccurs="2" maxOccurs="2"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="chessPiece">
    <xs:attribute name="position" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:integer">
          <xs:maxInclusive value="88"/>
          <xs:minInclusive value="11"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
    <xs:attribute name="isCaptured" type="xs:boolean" use="required"/>
  </xs:complexType>
</xs:schema>

I want the position of each chessPiece to be unique, but I can't find any schema examples online of the unique element applied that actually break up the schema into individual complexTypes and simpleTypes. 
What am I doing wrong here? 

A:

The problem comes from your selector.  You expect the @position attribute to be set on the <chessgame> element, whereas the tags where the uniqueness needs to be checked is two levels lower. 
This selector works fine:
<xs:selector xpath="*/*"/>

If you need the selector to be less general than the above is, you may use this one -- to be completed with the exhaustive list of tags:
<xs:selector xpath="pawns/whitePawn | pawns/blackPawn | knights/whiteKnight | knights/blackKnight"/>

