title: How add more chapter in chapter metadata xml
body: <p>A <code>chapter-metadata.xml</code> store in each book isbn folder(there are 100 isbn folder so there is 100 <code>chapter-metadata.xml</code>) which store in marklogic database server and chapter-metadata. Xml either contain data of one chapter or empty. If <code>chapter-metadata.xml</code> contain only one chapter information then I want to add more chapter information(my chapter infomation is common for all chapter) under chapter element with attribute and value of that chapter up to how many chapter store in book isbn folder(that I can fetch and store in a variable <code>$chapter_sequence</code> like ch001 ch002 ch003 ch004..) or if <code>chapter-metadata.xml</code> does not have any chaper information then it will create chapter element with attribute and value of chapter number and add my information, below I have put some xml structure if there is one chapter information and my information is from element keywordset</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
  &lt;chaptermetadata&gt;
  &lt;bookisbn&gt;isbn number&lt;/bookisbn&gt;
  &lt;booktitle&gt;Copyright&lt;/booktitle&gt;
  &lt;chapter id="ch001""&gt;
  &lt;keywordset&gt;
  &lt;keyword role="primary"&gt;context&lt;/keyword&gt; 
  &lt;keyword role="secondary"&gt;Copyright&lt;/keyword&gt; 
  &lt;keyword role="tertiary"&gt;subject&lt;/keyword&gt;
  &lt;/keywordset&gt; 
  &lt;/chapter&gt;
  &lt;/chaptermetadata&gt;
  </code></pre>
  
  <p>I want like below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt; 
  &lt;chaptermetadata&gt;
  &lt;bookisbn&gt;isbn number&lt;/bookisbn&gt;
  &lt;booktitle&gt;Copyright&lt;/booktitle&gt;
  &lt;chapter id="ch001""&gt;
  &lt;keywordset&gt;
  &lt;keyword role="primary"&gt;context&lt;/keyword&gt; 
  &lt;keyword role="secondary"&gt;Copyright&lt;/keyword&gt; 
  &lt;keyword role="tertiary"&gt;subject&lt;/keyword&gt;
  &lt;/keywordset&gt; 
  &lt;/chapter&gt;
  
  &lt;chapter id="ch002""&gt;
  &lt;keywordset&gt;
  &lt;keyword role="primary"&gt;context&lt;/keyword&gt; 
  &lt;keyword role="secondary"&gt;Copyright&lt;/keyword&gt; 
  &lt;keyword role="tertiary"&gt;subject&lt;/keyword&gt;
  &lt;/keywordset&gt; 
  &lt;/chapter&gt;
  so on to last chapter which I store in veriable
  &lt;/chaptermetadata&gt;
  </code></pre>
  
  <p>thanks,</p>
  
  <p>raj  </p>