title: XSLT - How to wrap adjacent elements with specific attributes
body: <p>I'm new to xsl.  I found something similar but can't quite tweak it to my use.</p>
  
  <p>Input:</p>
  
  <pre><code>&lt;section&gt;
    &lt;heading&gt;some heading text&lt;/heading&gt;
    &lt;amendment chapter="1"&gt;
      &lt;foo/&gt;
    &lt;/amendment&gt;
    &lt;amendment chapter="2"&gt;
      &lt;bar/&gt;
    &lt;/amendment&gt;
    &lt;amendment chapter="3"&gt;
      &lt;baz/&gt;
    &lt;/amendment&gt;
    &lt;heading&gt;some heading text&lt;/heading&gt;
    &lt;amendment chapter="1"&gt;
      &lt;baz/&gt;
    &lt;/amendment&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>To wrap elements with attribute "chapter='1' or chapter='2'".
  Output:</p>
  
  <pre><code>&lt;section&gt;
    &lt;heading&gt;some heading text&lt;/heading&gt;
    &lt;newwrapper&gt;
      &lt;amendment chapter="1"&gt;
        &lt;foo/&gt;
      &lt;/amendment&gt;
      &lt;amendment chapter="2"&gt;
        &lt;bar/&gt;
      &lt;/amendment&gt;
    &lt;/newwrapper&gt;
    &lt;amendment chapter="3"&gt;
      &lt;baz/&gt;
    &lt;/amendment&gt;
    &lt;heading&gt;some heading text&lt;/heading&gt;
    &lt;newwrapper&gt;
      &lt;amendment chapter="1"&gt;
        &lt;baz/&gt;
      &lt;/amendment&gt;
    &lt;/newwrapper&gt;
  &lt;/section&gt;
  </code></pre>