[xslt] AVT handling for xsl:attribute/@grouping-size



XSLT-sters,

  Is the grouping-size attribute of xsl:number an attribute
value template?  The spec says:

    The xsl:number element is used to insert a formatted number
    into the result tree. The number to be inserted may be specified
    by an expression. The value attribute contains an expression.
    The expression is evaluated and the resulting object is converted
    to a number as if by a call to the number function. The number
    is rounded to an integer and then converted to a string using
    the attributes specified in [7.7.1 Number to String Conversion
    Attributes]; in this context, the value of each of these
    attributes is interpreted as an attribute value template.

But this XSLT:

      <!-- Show the oldest five deceased authors -->
      <xsl:for-each select="$authors/author[life-span/born and life-span/died]">
        <xsl:sort select="life-span/died - life-span/born" order="descending"/>
        <xsl:variable name="gsize" select="1"/>
        <xsl:if test="position() &lt;= 5">
          <xsl:element name="oldest">
            <xsl:attribute name="gsize">
              <xsl:value-of select="$gsize"/>
            </xsl:attribute>
            <xsl:attribute name="age">
              <xsl:number value="life-span/died - life-span/born" grouping-size="1" grouping-separator="."/>
            </xsl:attribute>
            <xsl:attribute name="age2">
              <xsl:number value="life-span/died - life-span/born" grouping-size="{$gsize}" grouping-separator="."/>
            </xsl:attribute>
            <xsl:attribute name="born">
              <xsl:value-of select="life-span/born"/>
            </xsl:attribute>
            <xsl:attribute name="died">
              <xsl:value-of select="life-span/died"/>
            </xsl:attribute>
            <xsl:attribute name="name">
              <xsl:value-of select="concat(name/first, &quot; &quot;, name/last)"/>
            </xsl:attribute>
          </xsl:element>
        </xsl:if>
      </xsl:for-each>

produces this output:

  <oldest gsize="1" age="8.9" age2="89" born="1886" died="1975" name="Rex Stout"/>
  <oldest gsize="1" age="8.8" age2="88" born="1906" died="1994" name="Michael Innes"/>
  <oldest gsize="1" age="8.7" age2="87" born="1895" died="1982" name="Ngaio Marsh"/>
  <oldest gsize="1" age="8.6" age2="86" born="1907" died="1993" name="Leslie Charteris"/>
  <oldest gsize="1" age="8.6" age2="86" born="1890" died="1976" name="Agatha Christie"/>

for a list of authors that looks like:

    <author>
      <name>
        <first>Agatha</first>
        <last>Christie</last>
      </name>
      <life-span>
        <born>1890</born>
        <died>1976</died>
      </life-span>
    </author>

The "age" attribute comes out as expected, but "age2" uses "{$gsize}"
which seems to have no affect at all.

Am I missing something or does this attribute need AVT processing?

Thanks,
 Phil


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]