title: XSLT getting the first row from a series of data
body: <p>I have seen some very similar questions, but the solutions don't seem to work in my case.   </p>
  
  <p>I have XML that looks like this. </p>
  
  <pre><code>&lt;AdLocInfo&gt;
              &lt;ExternalRunSchedNumber/&gt;
              &lt;RunSchedule-id&gt;280896&lt;/RunSchedule-id&gt;
              &lt;publication-id&gt;181&lt;/publication-id&gt;
              &lt;publication&gt;SWEB&lt;/publication&gt;
              &lt;publication-placement-id&gt;10&lt;/publication-placement-id&gt;
              &lt;publication-placement&gt;Legals&lt;/publication-placement&gt;
              &lt;publication-position-id&gt;21&lt;/publication-position-id&gt;
              &lt;publication-position&gt;Legal - Notices&lt;/publication-position&gt;
              &lt;import-price&gt;0.00&lt;/import-price&gt;
              &lt;rundates&gt;
                  &lt;date Insertion-id="1530082" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05042017 15:30:00"&gt;05062017&lt;/date&gt;
                  &lt;date Insertion-id="1530083" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05052017 15:30:00"&gt;05072017&lt;/date&gt;
                  &lt;date Insertion-id="1530084" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05052017 15:30:00"&gt;05082017&lt;/date&gt;
                  &lt;date Insertion-id="1530085" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05082017 15:30:00"&gt;05092017&lt;/date&gt;
                  &lt;date Insertion-id="1530086" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05092017 15:30:00"&gt;05102017&lt;/date&gt;
                  &lt;date Insertion-id="1530087" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05102017 15:30:00"&gt;05112017&lt;/date&gt;
                  &lt;date Insertion-id="1530088" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05112017 15:30:00"&gt;05122017&lt;/date&gt;
                  &lt;date Insertion-id="1530089" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05112017 15:30:00"&gt;05132017&lt;/date&gt;
                  &lt;date Insertion-id="1530090" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05122017 15:30:00"&gt;05142017&lt;/date&gt;
                  &lt;date Insertion-id="1530091" InvoicedAlreadyFlag="true" PublishedFlag="true" Deadline="05122017 15:30:00"&gt;05152017&lt;/date&gt;
  </code></pre>
  
  <p>I want to pull the first and last dates from the series.   </p>
  
  <p>My XSL looks like this: </p>
  
  <pre><code>&lt;xsl:for-each select="AdBaseInfo"&gt;
          &lt;ad&gt;
              &lt;paperId&gt;5344&lt;/paperId&gt;
              &lt;paperItemId&gt;
                  &lt;xsl:value-of select="Ad/AdNumber"/&gt;
              &lt;/paperItemId&gt;
              &lt;itemDesc&gt;
                  &lt;!--&lt;xsl:text disable-output-escaping="yes"&gt;&amp;lt;![CDATA[&lt;/xsl:text&gt;--&gt;
                  &lt;xsl:value-of select="Ad/ad-content"/&gt;
                  &lt;!--&lt;xsl:text disable-output-escaping="yes"&gt;]]&amp;gt;&lt;/xsl:text&gt;--&gt;
              &lt;/itemDesc&gt;
              &lt;startDate&gt;
                  &lt;xsl:for-each select="//date[1]"&gt;
                     &lt;xsl:value-of select="concat(substring(., 5, 4), '-', substring(., 1, 2), '-', substring(., 3, 2))" /&gt;
                  &lt;/xsl:for-each&gt;
              &lt;/startDate&gt;
  </code></pre>
  
  <p>But that results in the first line from each of the records in the XML file. </p>
  
  <pre><code>&lt;ad&gt;
  &lt;paperId&gt;5344&lt;/paperId&gt;
  &lt;paperItemId&gt;0000119016-01&lt;/paperItemId&gt;
  &lt;itemDesc/&gt;
  &lt;startDate&gt;2017-05-062017-05-242017-06-012017-06-012017-06-082017-05-272017-06-082017-06-082017-06-072017-06-072017-06-082017-06-082017-07-012017-06-082017-06-082017-06-072017-06-082017-06-10&lt;/startDate&gt;
  &lt;expDate/&gt;
  &lt;categoryId&gt;S-Main Legal ROP&lt;/categoryId&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated. </p>