title: xslt template- how do I pass in the attribute and its value?
body: <p>I'm working with some XML where the nodes have lots of attributes, and I'm creating an FO PDF file (report) using XSL.  I'm trying to create a template that takes a specific attribute on the current node, and create an <code>fo:block</code> that will have some basic formatting.</p>
  
  <p>Here is a template that creates a big list of all the attributes and values on one node.</p>
  
  <p>XSL:</p>
  
  <pre><code>&lt;xsl:template name="createAttributeAndValueList"&gt;
      &lt;xsl:param name="node" select="." /&gt;
      &lt;xsl:for-each select="$node/@*"&gt;
          &lt;fo:block&gt;
          &lt;xsl:value-of select="concat(name(),':   ')"/&gt;
          &lt;xsl:value-of select="."/&gt;
          &lt;/fo:block&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>However, there are times when I only want to get one or two of these attributes out, instead of all of them off the node. I'm guessing this is something that would be really obvious, but that I haven't figured out yet due to my inexperience.</p>
  
  <p>I am trying to do the same formatting, but I just can't seem to get the syntax right to be able to pass in my value to the parameter, and get what I want.  Here's what I have:</p>
  
  <p>XSL:</p>
  
  <pre><code>&lt;xsl:template name="createAttributeValuePair"&gt;
      &lt;xsl:param name="attribute" select="." /&gt;
      &lt;xsl:for-each select="@*"&gt;
          &lt;fo:block&gt;
          &lt;xsl:value-of select="concat(name(),':   ')"/&gt;
          &lt;xsl:value-of select="."/&gt;
          &lt;/fo:block&gt;
      &lt;/xsl:for-each&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>And here's how I'm trying to call it:
  XSL:</p>
  
  <pre><code>&lt;fo:block font-weight="normal" margin-left="6pt"&gt;
      &lt;xsl:call-template name="createAttributeValuePair"&gt;
          &lt;xsl:with-param name="attribute"                                     
                          select="/device:DevicePatientEncounter/device:Encounter/
                                       device:Followup/@UnderlyingRhythm"/&gt;
      &lt;/xsl:call-template&gt;
  &lt;/fo:block&gt;
  </code></pre>
  
  <p>where my XML looks like this:</p>
  
  <pre><code>&lt;DevicePatientEncounter xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                          xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                          GeneratedTime="2011-12-14T13:36:05" 
                          EncounterDate="2011-11-15T11:04:54" 
                          xmlns="device"&gt;
      &lt;Encounter&gt;
          &lt;Followup UnderlyingRhythm="Sinus bradycardia" 
                    UnderlyingRhythmRateBpm="44" 
                    IsPmDependent="false" 
                    PresentingRhythm="Atrial fibrillation" 
                    BatteryChargeSeconds="5" 
                    AutoCapFrequency="3 Years" 
                    LastCapacitorFormDate="2011-10-25T00:00:00" 
                    BatteryLongevity="0" 
                    BatteryVoltage="11" 
                    BatteryStatus="MOL"/&gt;
      &lt;/Encounter&gt;
  &lt;/DevicePatientEncounter&gt;
  </code></pre>