title: How do I include an XML Schema Declaration inside of the same file as the XML data?
body: <p>How do you do it?</p>
  
  <p>Here's my attempt for reference, but I don't think I'm doing it correctly:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  
  &lt;X:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://x.iaesr.com"&gt;
      &lt;X:element name="track"&gt;
          &lt;X:complexType&gt;
              &lt;X:sequence&gt;
                  &lt;X:element name="title" type="X:string" /&gt;
                  &lt;X:element name="length" type="X:time" use="optional" /&gt;
                  &lt;X:element name="featuring" type="X:string" use="optional" /&gt;
              &lt;/X:sequence&gt;
              &lt;X:attribute name="track_number" type="X:int" use="optional" /&gt;
          &lt;/X:complexType&gt;
      &lt;/X:element&gt;
      &lt;X:element name="cd_collection"&gt;
          &lt;X:complexType&gt;
              &lt;X:sequence&gt;
                  &lt;X:element name="album" minOccurs="1"&gt;
                      &lt;X:complexType&gt;
                          &lt;X:sequence&gt;
                              &lt;X:element name="id" type="X:int" /&gt;
                              &lt;X:element name="title" type="X:string" /&gt;
                              &lt;X:element name="artist" type="X:string" /&gt;
                          &lt;/X:sequence&gt;
                          &lt;!--
                              The following use of of the schema:choice element makes having a Disk item in the
                              Album element optional. In either case, it ensures that an album contains either
                              Disk elements with Track elements in them, or just Track elements alone, but never
                              both at the same level.
                          --&gt;
                          &lt;X:choice&gt;
                              &lt;X:element name="disk" minOccurs="1"&gt;
                                  &lt;X:complexType&gt;
                                      &lt;X:sequence&gt;
                                          &lt;X:element ref="track" minOccurs="1" /&gt;
                                      &lt;/X:sequence&gt;
                                      &lt;X:attribute name="id" type="X:int" /&gt;
                                  &lt;/X:complexType&gt;
                              &lt;/X:element&gt;
                              &lt;X:element ref="track" minOccurs="1" /&gt;
                          &lt;/X:choice&gt;
                          &lt;X:attribute name="label" type="X:string" /&gt;
                      &lt;/X:complexType&gt;
                  &lt;/X:element&gt;
              &lt;/X:sequence&gt;
          &lt;/X:complexType&gt;
      &lt;/X:element&gt;
  &lt;/X:schema&gt;
  
  &lt;cd_collection xmlns="http://x.iaesr.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="joePeaCDCollection.xsd"&gt;
      &lt;album label="Raisin Records"&gt;
      &lt;disk id="1"&gt;
          &lt;id&gt;1&lt;/id&gt;
          &lt;title&gt;Barenaked Ladies Are Men&lt;/title&gt;
          &lt;artist&gt;Barenaked Ladies&lt;/artist&gt;
          &lt;track track_number="1"&gt;
              &lt;title&gt;Serendipity&lt;/title&gt;
              &lt;length&gt;00:04:11&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="2"&gt;
              &lt;title&gt;Something You'll Never Find&lt;/title&gt;
              &lt;length&gt;00:04:57&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="3"&gt;
              &lt;title&gt;One and Only&lt;/title&gt;
              &lt;length&gt;00:03:47&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="4"&gt;
              &lt;title&gt;Angry People&lt;/title&gt;
              &lt;length&gt;00:04:01&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="5"&gt;
              &lt;title&gt;Down To Earth&lt;/title&gt;
              &lt;length&gt;00:03:46&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="6"&gt;
              &lt;title&gt;Beautiful&lt;/title&gt;
              &lt;length&gt;00:02:35&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="7"&gt;
              &lt;title&gt;Running Out Of Ink&lt;/title&gt;
              &lt;length&gt;00:03:58&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="8"&gt;
              &lt;title&gt;Half a Heart&lt;/title&gt;
              &lt;length&gt;00:04:27&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="9"&gt;
              &lt;title&gt;Maybe Not&lt;/title&gt;
              &lt;length&gt;00:03:00&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="10"&gt;
              &lt;title&gt;I Can I Will I Do&lt;/title&gt;
              &lt;length&gt;00:03:08&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="11"&gt;
              &lt;title&gt;Fun &amp;amp; Games&lt;/title&gt;
              &lt;length&gt;00:03:45&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="12"&gt;
              &lt;title&gt;The New Sad&lt;/title&gt;
              &lt;length&gt;00:02:34&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="13"&gt;
              &lt;title&gt;Quality&lt;/title&gt;
              &lt;length&gt;00:04:15&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="14"&gt;
              &lt;title&gt;Another Spin&lt;/title&gt;
              &lt;length&gt;00:04:05&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="15"&gt;
              &lt;title&gt;What A Letdown&lt;/title&gt;
              &lt;length&gt;00:03:49&lt;/length&gt;
          &lt;/track&gt;
          &lt;track track_number="16"&gt;
              &lt;title&gt;Why Say Anything Nice?&lt;/title&gt;
              &lt;length&gt;00:03:42&lt;/length&gt;
          &lt;/track&gt;
      &lt;/disk&gt;
      &lt;/album&gt;
      &lt;album label="Virgin Records"&gt;
          &lt;id&gt;2&lt;/id&gt;
          &lt;title&gt;Live From Mars&lt;/title&gt;
          &lt;artist&gt;Ben Harper&lt;/artist&gt;
          &lt;disk id="1"&gt;
              &lt;track track_number="1"&gt;
                  &lt;title&gt;Glory &amp;amp; Consequence&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="2"&gt;
                  &lt;title&gt;Excuse Me Mr.&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="3"&gt;
                  &lt;title&gt;Alone&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="4"&gt;
                  &lt;title&gt;Sexual Healing&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="5"&gt;
                  &lt;title&gt;Woman in You&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="6"&gt;
                  &lt;title&gt;Ground on Down&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="7"&gt;
                  &lt;title&gt;Steal My Kisses&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="8"&gt;
                  &lt;title&gt;Burn One Down&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="9"&gt;
                  &lt;title&gt;Mama's Got a Girlfriend&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="10"&gt;
                  &lt;title&gt;Welcome to the Cruel World&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="11"&gt;
                  &lt;title&gt;Forgiven&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="12"&gt;
                  &lt;title&gt;Faded/Whole Lotta Love&lt;/title&gt;
              &lt;/track&gt;
          &lt;/disk&gt;
          &lt;disk id="2"&gt;
              &lt;track track_number="1"&gt;
                  &lt;title&gt;Waiting on an Angel&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="2"&gt;
                  &lt;title&gt;Roses from My Friends&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="3"&gt;
                  &lt;title&gt;Power of the Gospel&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="4"&gt;
                  &lt;title&gt;Pleasure and Pain&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="5"&gt;
                  &lt;title&gt;Please Bleed&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="6"&gt;
                  &lt;title&gt;The Drugs Don't Work&lt;/title&gt;
                  &lt;featuring&gt;Richard Ashcroft&lt;/featuring&gt;
              &lt;/track&gt;
              &lt;track track_number="7"&gt;
                  &lt;title&gt;In the Lord's Arms&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="8"&gt;
                  &lt;title&gt;Not Fire, Not Ice&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="9"&gt;
                  &lt;title&gt;Beloved One&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="10"&gt;
                  &lt;title&gt;Number Three&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="11"&gt;
                  &lt;title&gt;Walk Away&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="12"&gt;
                  &lt;title&gt;Another Lonely Day&lt;/title&gt;
              &lt;/track&gt;
              &lt;track track_number="13"&gt;
                  &lt;title&gt;Like a King/I'll Rise&lt;/title&gt;
              &lt;/track&gt;
          &lt;/disk&gt;
      &lt;/album&gt;
  &lt;/cd_collection&gt;
  </code></pre>