Edit in JSFiddle

<!-- results -->
<div id="pnlResults"></div>

<!-- xml data -->
<script id="xml" type="application/xml">
    <expenses>
        <x id="1" month="Jan" amount-gas="149.95" amount-electric="65.73" amount-water="29.73" amount-other="107.35" />
        <x id="2" month="Feb" amount-gas="125.95" amount-electric="67.99" amount-water="30.55" amount-other="105.99" />
        <x id="3" month="Mar" amount-gas="100.99" amount-electric="68.99" amount-water="29.99" amount-other="107.10" />
        <x id="4" month="Apr" amount-gas="100.59" amount-electric="67.29" amount-water="30.29" amount-other="100.50" />
        <x id="5" month="May" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="6" month="Jun" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="7" month="Jul" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="8" month="Aug" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="9" month="Sep" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="10" month="Oct" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="11" month="Nov" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
        <x id="12" month="Dec" amount-gas="0" amount-electric="0" amount-water="0" amount-other="0" />
    </expenses>
</script>

<!-- xsl data -->
<script id="xsl" type="application/xml">
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output media-type="html" omit-xml-declaration="yes" indent="yes" />
       
        <!-- variables -->
        <xsl:param name="SortExpression" />
        <xsl:param name="SortDirection" />
        <xsl:param name="SortType" />
        
        <!-- templates -->
        <xsl:template match="/">            
          <table id="expenses" border="0" cellpadding="3" cellspacing="0">
            <thead>
              <tr>
                <th align="left" style="width: 100px">
                  Month
                </th>
                <th align="right" style="width: 125px">
                  Gas
                </th>
                <th align="right" style="width: 125px">
                  Electric
                </th>
                <th align="right" style="width: 125px">
                  Water
                </th>
                <th align="right" style="width: 125px">
                  Other
                </th>
                <th align="right" style="width: 125px">
                  Total
                </th>
              </tr>
            </thead>
    
            <tbody>
              <xsl:apply-templates select="//x">            
                <xsl:sort select="@*[name() = $SortExpression]" order="{$SortDirection}" data-type="{$SortType}" />
              </xsl:apply-templates>
            </tbody>
    
            <tfoot>
              <tr style="font-weight: bold">
                <td align="left">
                  Totals
                </td>
                <td align="right">
                  <span id="lbl-total-gas">
                    <xsl:value-of select="format-number(sum(//x/@amount-gas), '#,###,##0.00')" />
                  </span>
                </td>
                <td align="right">
                  <span id="lbl-total-electric">
                    <xsl:value-of select="format-number(sum(//x/@amount-electric), '#,###,##0.00')" />
                  </span>
                </td>
                <td align="right">
                  <span id="lbl-total-water">
                    <xsl:value-of select="format-number(sum(//x/@amount-water), '#,###,##0.00')" />
                  </span>
                </td>
                <td align="right">
                  <span id="lbl-total-other">
                    <xsl:value-of select="format-number(sum(//x/@amount-other), '#,###,##0.00')" />
                  </span>
                </td>
                <td align="right">
                  <span id="lbl-total-sum">
                    <xsl:value-of select="format-number(sum(//x/@*[contains(name(.), 'amount-')]), '#,###,##0.00')" />
                  </span>
                </td>
              </tr>
            </tfoot>
          </table>
      </xsl:template>
    
      <xsl:template match="x">
        <tr id="expense-data" data-row="{position()}">
          <td>
            <xsl:value-of select="@month" />
          </td>
          <td align="right">
            <input type="text" id="txtAmountGas{position()}" name="txtAmountGas{position()}" value="{format-number(@amount-gas, '#,###,##0.00')}" class="amount gas total{position()}" data-row="{position()}" data-column="gas" style="width: 100px; text-align: right" maxlength="8" />
          </td>
          <td align="right">
            <input type="text" id="txtAmountElectric{position()}" name="txtAmountElectric{position()}" value="{format-number(@amount-electric, '#,###,##0.00')}" class="amount electric total{position()}" data-row="{position()}" data-column="electric" style="width: 100px; text-align: right" maxlength="8" />
          </td>
          <td align="right">
            <input type="text" id="txtAmountWater{position()}" name="txtAmountWater{position()}" value="{format-number(@amount-water, '#,###,##0.00')}" class="amount water total{position()}" data-row="{position()}" data-column="water" style="width: 100px; text-align: right" maxlength="8" />
          </td>
          <td align="right">
            <input type="text" id="txtAmountOther{position()}" name="txtAmountOther{position()}" value="{format-number(@amount-other, '#,###,##0.00')}" class="amount other total{position()}" data-row="{position()}" data-column="other" style="width: 100px; text-align: right" maxlength="8" />
          </td>
          <td align="right">
            <span id="lbl-total-{position()}">
              <xsl:value-of select="format-number(sum(current()/@*[contains(name(.), 'amount-')]), '#,###,##0.00')" />
            </span>
          </td>
        </tr>
      </xsl:template>
    </xsl:stylesheet>
</script>