title: Combine multiple XML files using XSLT and do some math function
body: <p>I have an XML file <strong>authors.xml</strong> as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;authors&gt;
    &lt;author&gt;
      &lt;name&gt;Leonardo da Vinci&lt;/name&gt;
      &lt;nationality&gt;Italian&lt;/nationality&gt;
    &lt;/author&gt;
    &lt;author&gt;
      &lt;name&gt;Pablo Picasso&lt;/name&gt;
      &lt;nationality&gt;Spanish&lt;/nationality&gt;
    &lt;/author&gt;
  &lt;/authors&gt;
  </code></pre>
  
  <p>and another file listing their artworks <strong>artworks.xml</strong> as below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;artworks&gt;
    &lt;artwork&gt;
      &lt;title&gt;Mona Lisa&lt;/title&gt;
      &lt;author&gt;Leonardo da Vinci&lt;/author&gt;
      &lt;date&gt;1497&lt;/date&gt;
      &lt;form&gt;painting&lt;/form&gt;
    &lt;/artwork&gt;
    &lt;artwork&gt;
      &lt;title&gt;Vitruvian Man&lt;/title&gt;
      &lt;author&gt;Leonardo da Vinci&lt;/author&gt;
      &lt;date&gt;1499&lt;/date&gt;
      &lt;form&gt;painting&lt;/form&gt;
    &lt;/artwork&gt;
    &lt;artwork&gt;
      &lt;title&gt;Absinthe Drinker&lt;/title&gt;
      &lt;author&gt;Pablo Picasso&lt;/author&gt;
      &lt;date&gt;1479&lt;/date&gt;
      &lt;form&gt;painting&lt;/form&gt;
    &lt;/artwork&gt;
    &lt;artwork&gt;
      &lt;title&gt;Chicago Picasso&lt;/title&gt;
      &lt;author&gt;Pablo Picasso&lt;/author&gt;
      &lt;date&gt;1950&lt;/date&gt;
      &lt;form&gt;sculpture&lt;/form&gt;
    &lt;/artwork&gt;
  &lt;/artworks&gt;
  </code></pre>
  
  <p>What I wish to do is combine these 2 XML files into another processed XML file. The XSLT will list down all authors, and within it list all the artworks associated with that particular author and group it by artwork form. The XSLT will also count the number of artwork groups. The duration of the group is also added as an element attribute. This is further illustrated as in the XML file below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;authors&gt;
    &lt;author&gt;
      &lt;name&gt;Leonardo da Vinci&lt;/name&gt;
      &lt;nationality&gt;Italian&lt;/nationality&gt;
      &lt;artworks form="painting" duration="1497-1499" quantity="2"&gt;
        &lt;artwork date="1497"&gt;
          &lt;title&gt;Mona Lisa&lt;/title&gt;
        &lt;/artwork&gt;
        &lt;artwork date="1499"&gt;
          &lt;title&gt;Vitruvian Man&lt;/title&gt;
        &lt;/artwork&gt;
      &lt;/artworks&gt;
    &lt;/author&gt;
    &lt;author&gt;
      &lt;name&gt;Pablo Picasso&lt;/name&gt;
      &lt;nationality&gt;Spanish&lt;/nationality&gt;
      &lt;artworks form="painting" duration="1479-1479" quantity="1"&gt;
        &lt;artwork date="1479"&gt;
          &lt;title&gt;Absinthe Drinker&lt;/title&gt;
        &lt;/artwork&gt;
      &lt;/artworks&gt;
      &lt;artworks form="sculpture" duration="1950-1950" quantity="1"&gt;
        &lt;artwork date="1950"&gt;
          &lt;title&gt;Chicago Picasso&lt;/title&gt;
        &lt;/artwork&gt;
      &lt;/artworks&gt;
    &lt;/author&gt;
  &lt;/authors&gt;
  </code></pre>
  
  <p>I am still new to this. What I've managed to do is get all the author part, and now I'm not sure how to extract the data from that other XML file while also counting the occurrence of artworks and so on. I am very experienced in procedural programming such as C or C++, but this method of declarative programming is really turning my head upside down! Hopefully someone can point me in the right direction so that I can get this right.</p>