title: XSLT Loop within a range from XML
body: <p>let's say I have following xml file:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;root&gt;
      &lt;header&gt;
          &lt;headernodes1/&gt;
          &lt;headernodes2/&gt;
      &lt;/header&gt;
      &lt;items&gt;
          &lt;itemno&gt;1&lt;/itemno&gt;
          &lt;itemtext&gt;first item&lt;/itemtext&gt;
          &lt;loop&gt;
              &lt;range&gt;
                  &lt;rangefrom&gt;4711&lt;/rangefrom&gt;
                  &lt;rangeto&gt;4713&lt;/rangeto&gt;
              &lt;/range&gt;
              &lt;content&gt;content in the first loop&lt;/content&gt;
          &lt;/loop&gt;
          &lt;loop&gt;
              &lt;range&gt;
                  &lt;rangefrom&gt;4715&lt;/rangefrom&gt;
                  &lt;rangeto&gt;4718&lt;/rangeto&gt;
              &lt;/range&gt;
              &lt;content&gt;content in the second loop&lt;/content&gt;
          &lt;/loop&gt;
      &lt;/items&gt;
      &lt;footernodes/&gt;
  &lt;/root&gt;
  </code></pre>
  
  <p>The header, footer and nodes in <code>&lt;item&gt;</code> before <code>&lt;loop&gt;</code> should just be copied. </p>
  
  <p>If <code>&lt;rangeto&gt;</code> not appears, then just copy the <code>&lt;loop&gt;</code> segment. Otherwise if it does appear, then replicate the <code>&lt;loop&gt;</code> segment like following example:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4711&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the first loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4712&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the first loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4713&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the first loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4715&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the second loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4716&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the second loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4717&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the second loop&lt;/content&gt;
  &lt;/loop&gt;
  &lt;loop&gt;
      &lt;range&gt;
          &lt;rangefrom&gt;4718&lt;/rangefrom&gt;
      &lt;/range&gt;
      &lt;content&gt;content in the second loop&lt;/content&gt;
  &lt;/loop&gt;
  </code></pre>
  
  <p>Is there a solution in XSLT 1.0?</p>
  
  <p>Thank you very much for your help &amp; advice. </p>
  
  <p>Greetings from Germany,
  L</p>