title: XML / XSD - How do I reference a complexType within Itself recursively?
body: <p>My question is very similar to <a href="https://stackoverflow.com/questions/2885514/what-xsd-will-let-an-element-have-itself-as-a-sub-element-infinitely">What xsd will let an element have itself as a sub element infinitely?</a> .</p>
  
  <p>What I want to do is utilize an XML structure that is able to create a Skeleton within XML. The XML will have a top level complexType that includes a recursive list of Bone complexTypes that include their own attributes and element data.</p>
  
  <p>The XML I am using is here:</p>
  
  <pre><code>&lt;SkeletalMapping xmlns="test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="test SkeletalDefinition.xsd"&gt;
  
  &lt;Skeleton sourceSkeleton="Max" targetSkeleton="UDK" version="1.0"&gt;
      &lt;Bone name="Origin" target="ROOT"&gt;
          &lt;PivotPoint x="0.0" y="0.0" z="0.0" /&gt;
          &lt;Bone name="UpperBody" target="SPINE"&gt;
              &lt;PivotPoint x="0.0" y="0.033" z="0.438" /&gt;
              &lt;Bone name="Head" target="HEAD"&gt;
                  &lt;PivotPoint x="0.0" y="0.006" z="0.667" /&gt;
              &lt;/Bone&gt;
              &lt;Bone name="RightArm" target="RIGHT_ARM"&gt;
                  &lt;PivotPoint x="-0.203" y="0.05" z="0.477" /&gt;
                  &lt;Bone name="LRightHand" target="RIGHT_HAND"&gt;
                      &lt;PivotPoint x="-0.586" y="0.074" z="0.067" /&gt;
                  &lt;/Bone&gt; &lt;!-- LeftHand --&gt;
              &lt;/Bone&gt; &lt;!-- LeftArm --&gt;
              &lt;Bone name="LeftArm" target="LEFT_ARM"&gt;
                  &lt;PivotPoint x="0.203" y="0.05" z="0.477" /&gt;
                  &lt;Bone name="LeftHand" target="LEFT_HAND"&gt;
                      &lt;PivotPoint x="0.587" y="0.074" z="0.066" /&gt;
                  &lt;/Bone&gt; &lt;!-- LeftHand --&gt;
              &lt;/Bone&gt; &lt;!-- LeftArm --&gt;
          &lt;/Bone&gt; &lt;!-- UpperBody --&gt;
          &lt;Bone name="RightLeg" target="RIGHT_LEG"&gt;
              &lt;PivotPoint x="-0.14" y="-0.019" z="-0.467" /&gt;
              &lt;Bone name="RightFoot" target="RIGHT_FOOT"&gt;
                  &lt;PivotPoint x="-0.17" y="0.083" z="-0.889" /&gt;
              &lt;/Bone&gt; &lt;!-- RightFoot --&gt;
          &lt;/Bone&gt; &lt;!-- RightLeg --&gt;
          &lt;Bone name="LeftLeg" target="LEFT_LEG"&gt;
              &lt;PivotPoint x="0.14" y="-0.019" z="-0.467" /&gt;
              &lt;Bone name="LeftFoot" target="LEFT_FOOT"&gt;
                  &lt;PivotPoint x="0.17" y="0.083" z="-0.889" /&gt;
              &lt;/Bone&gt; &lt;!-- LegFoot --&gt;
          &lt;/Bone&gt; &lt;!-- LeftLeg --&gt;
      &lt;/Bone&gt; &lt;!-- Origin --&gt;
  &lt;/Skeleton&gt;
  </code></pre>
  
  <p>The XSD That I am using is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;
  
      &lt;xs:complexType name="Vec3"&gt;
          &lt;xs:attribute name="x" type="xs:float"/&gt;
          &lt;xs:attribute name="y" type="xs:float"/&gt;
          &lt;xs:attribute name="z" type="xs:float"/&gt;
      &lt;/xs:complexType&gt;
  
      &lt;xs:element name="Bone"&gt;
          &lt;xs:complexType mixed="true"&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="Bone" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;/xs:sequence&gt;
              &lt;xs:element name="PivotPoint" type="Vec3" minOccurs="0" maxOccurs="1"/&gt;
              &lt;xs:attribute name="name" type="xsd:string" use="required"/&gt;
              &lt;xs:attribute name="target" type="xsd:string" /&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:element name="Skeleton"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence&gt;
                  &lt;xs:element ref="Bone" minOccurs="0" maxOccurs="unbounded"/&gt;
              &lt;/xs:sequence&gt;
              &lt;xs:attribute name="sourceSkeleton" type="xs:string" /&gt;
              &lt;xs:attribute name="targetSkeleton" type="xs:string" /&gt;
              &lt;xs:attribute name="version" type="xs:string" /&gt;
          &lt;/xs:complexType&gt;
      &lt;/xs:element&gt;
  
      &lt;xs:element name="SkeletonMapping"&gt;
          &lt;xs:complexType&gt;
              &lt;xs:sequence minOccurs="0" maxOccurs="unbounded"&gt;
                  &lt;xs:element ref="Skeleton"/&gt;
              &lt;/xs:sequence&gt;
          &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>The Editor I am using is Notepad++ with the XML plugins. The XML and XSD Syntax passes validation, however I can't figure out why the XML Tool validation of the XSD says it is unable to parse the XML.</p>
  
  <p>If anyone knows how I can fix this please let me know, as I've tried breaking the Bone inheritance from:</p>
  
  <pre><code>&lt;Skeleton&gt;
      &lt;Bone&gt;
          &lt;Bone&gt;
              &lt;Bone/&gt;
          &lt;/Bone&gt;
      &lt;/Bone&gt;
  &lt;/Skeleton&gt;
  </code></pre>
  
  <p>to </p>
  
  <pre><code>&lt;Skeleton&gt;
      &lt;BoneGroup&gt;
          &lt;Bone&gt;
              &lt;BoneGroup&gt;
                  &lt;Bone&gt;
                      &lt;BoneGroup&gt;
                          &lt;Bone/&gt;
                      &lt;/BoneGroup&gt;
                  &lt;/Bone&gt;
              &lt;/BoneGroup&gt;
          &lt;/Bone&gt;
      &lt;/BoneGroup&gt;
  &lt;/Skeleton&gt;
  </code></pre>
  
  <p>, for which I created a new element BoneGroup that had a ref to Bone, and Bone had a ref to BoneGroup, but that didn't work out any better.</p>