GNOME Bugzilla – Bug 623855
Missing AVT handling for xsl:attribute/@grouping-size
Last modified: 2021-07-05 11:01:14 UTC
The grouping-size attribute of xsl:number is an attribute value template but is missing the proper expansion. 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() <= 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" group ing-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, " ", 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.
Looks like libxslt/preproc.c:xsltNumberComp() is missing AVT handling for all the attributes of xsl:number. Calls to xsltEvalStaticAttrValueTemplate() are needed.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxslt/-/issues/ Thank you for your understanding and your help.