XSLT write to same attribute from multiple template matches
<p>I have XML that uses a number of custom attributes, but when round-tripping to standard output (DITA in this case), I need to push values from multiple custom attributes into the same single output attribute. These values may come from templates that match the element itself or one of its ancestors.</p>

<p>Here is a simplified example:</p>

<pre><code>&lt;concept&gt;
    &lt;title&gt;Test concept&lt;/test&gt;
    &lt;conbody&gt;
        &lt;p&gt;Info valid for everything and everyone&lt;/p&gt;
        &lt;p brand="product1"&gt;Some product-specific info here&lt;/p&gt;
        &lt;p brand="product2" country="NL"&gt;Even more specific info&lt;/p&gt;
        &lt;p country="NL"&gt;And this is merely localised stuff&lt;/p&gt;
    &lt;/conbody&gt;
&lt;/concept&gt;
</code></pre>

<p>The result of my transform should be valid DITA, which would look like this:</p>

<pre><code>&lt;concept&gt;
    &lt;title&gt;Test concept&lt;/test&gt;
    &lt;conbody&gt;
        &lt;p&gt;Info valid for everything and everyone&lt;/p&gt;
        &lt;p props="brand(product1)"&gt;Some product-specific info here&lt;/p&gt;
        &lt;p props="brand(product2) country(NL)"&gt;Even more specific info&lt;/p&gt;
        &lt;p props="country(NL)"&gt;And this is merely localised stuff&lt;/p&gt;
    &lt;/conbody&gt;
&lt;/concept&gt;
</code></pre>

<p>When I try to write into the same attribute from various template matches (each one matching one single attribute on any node), only one value appears in the output. I could rework the template to use two passes but in some cases I would need three, or even more, which makes it really complicated. Creating more specific templates that fire when one, or two, or more attributes exist that need to be combined into one quickly becomes a huge list of templates.</p>

<p>The easiest method would be to add a value to an attribute that is created by another template, but I am not sure whether that can be done at all in XSLT 2.0 - as the result of one transform is not available for the other. I am not enough of an expert yet to know whether anything exists that helps me create a maintainable XSL. If there is no such option, I guess I will have to create a fairly complicated multi-pass template after all.</p>

<p>Thanks for either a positive answer ("yes, you can do it and here is how") or a negative one ("no, this cannot be done in XSL 2.0").</p>