title: Replacing the content of an element by the value of an arbitrary attribute with XSLT 2.0
body: <p>I need to replace the content of an element by the value of an arbitrary attribute, if the elemnt has this attribute. I need to do that with an XSLT sheet (2.0), but I have no idea how I could do such a thing.</p>
  
  <p>For example, let's say I have this xml document.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;document&gt; 
    Hi my name is &lt;tag-A flag="Bob"&gt;Leopold&lt;/tag-A&gt;
    and I'm fond of &lt;tag-B flag="coding"&gt;literature&lt;/tag-B&gt;
    unless in the &lt;tag-C whatever="evening"&gt;morning&lt;/tag-C&gt;
  &lt;/document&gt;
  </code></pre>
  
  <p>Then the xslt would change the content of any element that has a <code>flag</code> attribute, let's say, for the value of that attribute and put everything enclosed in a <code>&lt;p&gt;</code> tag. This is the output I would get in that case.</p>
  
  <pre><code>&lt;p&gt;Hi my name is Bob
  and I'm fond of coding
  unless in the morning&lt;/p&gt;
  </code></pre>
  
  <p>How can I do such a thing?</p>